I want to have userinterface same as following pic for my app. my means that have different color for each item of listview just in one side programically. But I have no idea how should i do this
For your list item layout you could try something like the following...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.9" >
</TextView>
<View
android:id="@+id/sidebar"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1" >
</View>
</LinearLayout>
Using android:layout_width="0dp"
with android:layout_weight
will mean the views will be sized proportionally. In my example 90% width for the TextView
and 10% width for the View
- you can adjust the ratios to get the effect you want.
Once you've done that you just need to override the getView
method of your list adapter to find the "sidebar" View
and set its background colour.