其实我正在创建一个listView,我想在其中插入图像和文本(两者都是水平对齐)。我在创建listView时编写的代码是。
private ListView lv1;
private String lv_arr[]={"Android","iPhone","BlackBerry","AndroidPeople","Android","iPhone","BlackBerry","AndroidPeople","Android","iPhone","BlackBerry","AndroidPeople"};
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.contact_activity);
lv1=(ListView)findViewById(R.id.ListView01);
lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
lv1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
/*Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();*/
String selecteditem = lv_arr[position];
Intent myIntent = new Intent(view.getContext(), ContactInfo.class);
myIntent.putExtra("item", selecteditem);
startActivity(myIntent);
}
});
}
在我的情况下,我只插入字符串,但我想要的是在列表中插入图像和字符串..请为我提示...
答案 0 :(得分:3)
http://android-codes-examples.blogspot.com/2011/03/multiple-listview-and-custom-listview.html
http://androidgenuine.com/?tag=text-and-image-on-a-listview-android
http://devblogs.net/2011/01/04/multicolumn-listview-with-image-icon/
http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/
http://w2davids.wordpress.com/android-listview-with-iconsimages-and-sharks-with-lasers/
答案 1 :(得分:1)