В этом коде я использовал 3 столбца, вы будете изменены согласно вашему ..
listview.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#bfffdf"
android:drawSelectorOnTop="false">
</ListView>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/text1"
android:textColor="#00ff00"
android:textSize="18sp"
android:layout_width="30dip"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
android:textColor="#ff0000"
android:textSize="18sp"
android:layout_width="110dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView android:id="@+id/text3"
android:textColor="#0000ff"
android:textSize="14sp"
android:layout_width="40dip"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
MainActivity.java
import java.util.ArrayList;
import java.util.HashMap;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;
public class MainActivity extends ListActivity {
static final ArrayList<HashMap<String,String>> list =
new ArrayList<HashMap<String,String>>();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
SimpleAdapter adapter = new SimpleAdapter(
this,
list,
R.layout.main,
new String[] {"rank","model","company"},
new int[] {R.id.text1,R.id.text2, R.id.text3}
);
populateList();
setListAdapter(adapter);
}
private void populateList() {
HashMap map = new HashMap();
map.put("rank", "1");
map.put("model", "Samsung Galaxy Nexus");
map.put("company", "Samsung");
list.add(map);
map = new HashMap();
map.put("rank", "2");
map.put("model", "Samsung Epic Touch 4G");
map.put("company", "Samsung");
list.add(map);
map = new HashMap();
map.put("rank", "3");
map.put("model", "HTC Evo 3D");
map.put("company", "HTC");
list.add(map);
map = new HashMap();
map.put("rank", "4");
map.put("model", "T-Mobile MyTouch 4G Slide");
map.put("company", "HTC");
list.add(map);
map = new HashMap();
map.put("rank", "5");
map.put("model", "Samsung Galaxy S II");
map.put("company", "Samsung");
list.add(map);
map = new HashMap();
map.put("rank", "6");
map.put("model", "Apple iPhone 4S 16GB");
map.put("company", "Apple");
list.add(map);
map = new HashMap();
map.put("rank", "7");
map.put("model", "Motorola Droid Razr");
map.put("company", "Motorola");
list.add(map);
map = new HashMap();
map.put("rank", "8");
map.put("model", "Motorola Droid Bionic");
map.put("company", "Motorola");
list.add(map);
map = new HashMap();
map.put("rank", "9");
map.put("model", "Samsung Focus S");
map.put("company", "Samsung ");
list.add(map);
map = new HashMap();
map.put("rank", "10");
map.put("model", "Samsung Focus Flash");
map.put("company", "Samsung");
list.add(map);
}
}