Android: Achieve the content inside the linear layout through Java -
i have sample content.xml textview hard coded right now. application requirement such these these have populated according results fetched db. suppose have service return list of string needs populated text in text view how can achieved in java code?
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="vertical"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 1" android:textcolor="#ffffff" android:textsize="20sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 2" android:textcolor="#ffffff" android:textsize="20sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 3" android:textcolor="#ffffff" android:textsize="20sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 4" android:textcolor="#ffffff" android:textsize="20sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 5" android:textcolor="#ffffff" android:textsize="20sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 6" android:textcolor="#ffffff" android:textsize="20sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="25dp" android:layout_margintop="25dp" android:text="content 7" android:textcolor="#ffffff" android:textsize="20sp" /> </linearlayout>
i'd recommend using listview items seem arranged in vertical linearlayout. it's matter of defining arrayadapter, row layout xml , filling adapter results database query.
Comments
Post a Comment