0

I have linearlayout in XML with 5 textviews and some other elements (progressbar, buttons etc.). All these elements are based on data from SQLite database. I can place the data to layout, but how can I make the app to create new linearlayout with all elements each time when user writes new row in database?

Also, how can I get number of rowId's that are in database?

Thanks!

  • 1
    Have you considered using a [ListView](http://developer.android.com/reference/android/widget/ListView.html)? – stkent Dec 25 '14 at 19:46
  • Thanks, I didn't think of that... Do you have some idea to get number of row id's that are in the database? – user3932494 Dec 25 '14 at 19:49
  • 2
    Does [this question and answer combo](http://stackoverflow.com/questions/6351606/how-to-get-the-row-count-of-a-query-in-android-using-sqlite) help? – stkent Dec 25 '14 at 19:57
  • Ok, adding the info as an answer to help anyone else who comes across this question. – stkent Dec 25 '14 at 20:04

1 Answers1

2

Try using a ListView to show a potentially-varying number of identically-laid-out rows. You can retrieve the row count of a database query using the getCount method of Cursor (see e.g. How to get the row count of a query in Android using SQLite?)

Community
  • 1
  • 1
stkent
  • 19,772
  • 14
  • 85
  • 111