I use a multi-column list-view to display data as like a grid, but I want a list-view with user-defined columns and rows with borders. Suggestions?
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
main1.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/cust"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="customer" />
<TextView
android:id="@+id/order"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="order" />
<TextView
android:id="@+id/freight"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="freight" />
<TextView
android:id="@+id/station"
android:layout_width="70dp"
android:layout_height="70dp"
android:text="station" />
</LinearLayout>
Method one :
1) implement a custom adapter
2) in the
getview()method, set a background (with border) to the view before returning it.Method two:
use
ArrayAdapter1) make an xml file which cointains a
TextViewwith a background(which has a border)2) pass the reference to this xml to the
ArrayAdapterHere’s a tutorial, in case you don’t know what i’m talking about.