samedi 13 février 2016

Saving Spinner selection into SQLite database

Hi I have looked over all the question related to saving the spinner into database and nothing seems to be working.

I have my Spinner populating from a different table in my db and the list is showing up when I create a new item in the app, but now I need to save that selection into the new table and it crashes on update because there is nothing in the column ive created or the spinner data.

here is my spinner code

 public ArrayAdapter loadSpinnerData() {

    Log.d("CON", "setting spinner data");

    Spinner s = (Spinner) findViewById(R.id.spinnerCategory);
    DatabaseHandler h = new DatabaseHandler(getApplicationContext());

    List<String> names = h.getAllNames();

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, names);

    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);




    return dataAdapter;


}

I've tried to add in the onItemSelectedListener but nothing seems to be working,

any help is much appreciated!! thanks

Aucun commentaire:

Enregistrer un commentaire