Reputation: 145
Using simple cursor adapter I retrieve 5 columns from a table using cursor query and display them using a listview. Everything goes well but the columns retrieved are displayed horizontally in the listview. I want them to be displayed one below the other like: TX_UID TX_NAME TX_AMOUNT TX_PARTICULARS
AND NOT LIKE (Displayed as of now): TX_UID TX_NAME TX_AMOUNT TX_PARTICULARS
String[] from = new String[]{ vivzHelper.TX_UID,
vivzHelper.TX_NAME,vivzHelper.TX_AMOUNT,vivzHelper.TX_PARTICULARS};
int[] to = new int[]
{R.id.textView,R.id.textView2,R.id.textView3,R.id.textView5 };
SimpleCursorAdapter cursorAdapter;
cursorAdapter = new SimpleCursorAdapter(getBaseContext(),
R.layout.customgetalltxrowforeditordelete , c , from , to , 0);
thislist.setAdapter(cursorAdapter);
thislist.setAdapter(cursorAdapter);
XML Layout:
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="35dp"
android:fastScrollEnabled="false"
android:divider="#FFCC00"
android:dividerHeight="2px"
android:smoothScrollbar="true"
android:background="@drawable/my_selecter"
/>
Upvotes: 0
Views: 64
Reputation: 564
In your customgetalltxrowforeditordelete xml file you need to do something like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/badge13"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@id/textView2"
android:layout_below = "@id/textView"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@id/textView3"
android:layout_below = "@id/textView2"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@id/textView4"
android:layout_below = "@id/textView3"
/>
you need to use layout_below attribute in your TextView providing top view's id in attribute.
Upvotes: 0
Reputation: 132992
columns retrieved are displayed horizontally in the listview. I want them to be displayed one below the other
Problem is related to customgetalltxrowforeditordelete
layout instead of ListView
.
To show TextView's in ListView row Vertically. use LinearLayout
with orientation
attribute to vertical
Upvotes: 2