• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

android multiple textview in single row dynamically

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i am a newbie to android and i want to add multiple textviews in single row as
i have 1000's of objects to display like this manner

sample text 1 sample text 2
sample text 3 sample text 4
...
...
...

my layout look likes
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/catagory_linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >



<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="266dp" >

<TableLayout
android:id="@+id/maintable"
android:layout_width="wrap_content"
android:layout_height="265dp"
android:shrinkColumns="*"
android:stretchColumns="*" >

<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>

</TableLayout>

</ScrollView>

</LinearLayout>


but don't know how to perform it dynamically
i stuck with it please help
thanks in adv
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think a table is a good view to use for this - precisely because it is not dynamic. You should look up ListView or its sibling the GridView and use that instead. You would create an Adapter that iterates over the values you want to display and creates the TextViews and assigns the values. By using an Adapter you can provide the data to / in the Adapter and have it provide the Views that will show up on the device. Since you want to have two TextViews per line, I would probably use the GridView, but the ListView is a bit more backwards compatible, so if you wanted the largest version coverage you might do a ListView and create your own extension of the ArrayAdapter which provides a LinearLayout with two TextViews side by side.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic