Function to load the spinner data from SQLite database | Android Development

/**
* Function to load the spinner data from SQLite database
* */
private void loadSpinnerData() {
// database handler
DatabaseHandler db = new DatabaseHandler(getApplicationContext());

// Spinner Drop down elements
List lables = db.getAllLabels();

// Creating adapter for spinner
ArrayAdapter dataAdapter = new ArrayAdapter(this,
android.R.layout.simple_spinner_item, lables);

// Drop down layout style – list view with radio button
dataAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

// attaching data adapter to spinner
spinner.setAdapter(dataAdapter);
}

Add a Comment

Your email address will not be published. Required fields are marked *