I am trying to create an app to enter records into a database (SQLite) which includes an option field with data selected from a drop-down list box or Spinner. I can create the Spinner from a string array input from Strings.xml but I want to make the data 'user editable,' but cannot find a way to create it. The latest effort below stops after reporting it is switching to the database (at the declaration and initialisation of 'colurs.')

	protected void onCreate(Bundle savedInstanceState)
		mDbHelper = new NamesDbAdapter(this);
		Log.d("onCreate", "Creating Edit screen");
		mConfirmButton = (Button) findViewById(R.id.confirm);
		mPremier = (EditText) findViewById(R.id.premier);
		mDenier = (EditText) findViewById(R.id.denier);
		mDetail = (EditText) findViewById(R.id.detail);
		mOptid = (Spinner) findViewById(R.id.spinner);
		Log.d("Edit recd","Reading options table");
		Cursor pallette=mDbHelper.readOptionsTable();
		Log.d("Edit recd","Setup spinner");
		//String[] mOptions;
		//String[] from = new String[] {NamesDbAdapter.KEY_OPTION};
		//int[] to = new int[] {R.id.text1};
		Log.d("Edit rec","Create adapter");
		//SimpleCursorAdapter picklist = new SimpleCursorAdapter(this,R.layout.names_row, pallette, from, to);
		ArrayAdapter<CharSequence> picklist = ArrayAdapter.createFromResource(this, R.array.choisir2, android.R.layout.simple_spinner_item);
		//setListAdapter(new ArrayAdapter(this, R.layout.list_item, pallette));
		Log.d("picklist","Switch to database list");
		Log.d("picklist","get number of options");
		int colurs=pallette.getCount();
		Log.d("Edit Rec","Pallete count ="+Integer.toString(colurs));
		for (int ix=0; ix<colurs;ix++)
		Log.d("Edit rec","Create dropdown");
		mOptid.setOnItemSelectedListener(new OptItemSelectedListener());
		Log.d("onCreate", "Find RowId");
		mRowId=savedInstanceState != null
			? savedInstanceState.getLong(NamesDbAdapter.KEY_ROWID)
			: -1;		

This is extracted from an activity 'NamesEditActivity' called from the main activity with an Intent, adapted from Donn Felker's book on android. The options table is created in the database as part of the onCreate class.

Inspecting the LogCat screen in Eclipse (version 3.7.0) the next line reports;
Activity Launch timeout has expired, giving up wake lock!

Why should the int declaration and initialisation not work, or is the problem elsewhere, and, am I on the right lines to create a Spinner using the data from SQLite?

6 Years
Discussion Span
Last Post by stevelg

Searching elsewhere I found a similar app which uses a simple cursor adapter similar to the NotePad app and creates a dropdown resource with it. This approach does require one field to be specifically


which I have corrected for but the list view does display the names from the table, only the right number of blank boxes!

I presume the simple cursor adapter should populate the 'from' string array with the contents from the database table.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.