0

I can say I'm new for android application devolepment. I want to give a example to tell you my question.

I'm getting some datas from database I need to create a lot of textviews to put datas into. I think here is some php devoloper, too. When I use php I write something like below.

foreach($database_datas as $data)
{
 echo "<li>" + $data["list_item"] + "</li>";
}

In android, can we embed? What's the method?

Yusuf Ali
  • 173
  • 1
  • 10

1 Answers1

0

Do you mean add a set of textviews programmatically? This code shows how to add one textview programmatically to a linear layout. You should be able to put that code in a loop and add multiple textviews.

Android: Add a textview to linear layout programmatically

You might also want to check out the doc pages of LinearLayout (http://developer.android.com/reference/android/widget/LinearLayout.html) and TextView (http://developer.android.com/reference/android/widget/TextView.html)

Community
  • 1
  • 1
user2275410
  • 80
  • 3
  • 8
  • is that the method android programmers always use? – Yusuf Ali Sep 24 '13 at 21:15
  • Yes, to add a textview programmatically.. which is what I think you want to do, do correct me if I'm wrong. You can read the data and start a new activity that would display this data. You can add the textviews to the layout of this activity programmatically using the above code. – user2275410 Sep 24 '13 at 22:09