android - Listview data from multiple db rows -
I am currently using a listview populated from a SQLite db.
Public set & lt; String & gt; GetData () {Set & lt; String & gt; Set = new hashet & lt; String & gt; (); String selectQuery = "select * from" + tab; SQLiteDatabase db = this.getReadableDatabase (); Cursor cursor = db.rawQuery (selectQuery, zero); If (cursor.moveToFirst ()) {to {set.add (cursor.getString (1)); } While (cursor.movetoonext ()); } Cursor.close (); Db.close (); Return set; } Then list view
Private void populateListView () {lv = (ListView) is populated from findViewById (R.id.listViewSetLocks); DatabaseHandler db = new databank (getApplicationContext ()); Set up & lt; String & gt; Set = db.getData (); & Lt; String & gt; List = New Arrestist & lt; String & gt; (Set); ArrayAdapter & LT; String & gt; ArrayAdapter = New Arrayheader & lt; String & gt; (This, android.R.layout.simple_list_item_1, list); Lv.setAdapter (arrayAdapter); RegisterForContextMenu (lv); } All this works perfectly. Ive decided to change the layout slightly and use 2 line list view so that I need to use the data in different rows of the database.
How is this the best way to achieve this?
Thank you
I think you might be asking that to read it Try: Lars Vogel does a lot of good tutorials
You want to create a custom adapter by enhancing the better array or cursor adapter.
Perhaps there is a look:
Comments
Post a Comment