How to populate Buttons from ListAdapter In Android
I am writing a questionaire app wherein four answers from SQLLite db need to be added to four normal buttons (not radiobButtons) in the view.
I am querying the database and getting the results as cursor.I am unable to attach the results to four buttons,but am able to attach the same to List View as below
Cursor c = sampleDB.rawQuery("SELECT Answer From'+SAMPLE_TABLE_NAME+'", null);
if (c != null ) {
if (c.moveToFirst()) {
do {
String firstName = c.getString(c.getColumnIndex("Answer"));
results.add(firstName);
}while (c.moveToN开发者_StackOverflow社区ext());
}
}
this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,results));
How do I attach the cursor results to the button?
I was able to solve this issue by creating a DB Adapter using factory pattern and creating the buttons dynamically.
精彩评论