我想在每個列表項中添加一個按鈕,當用戶按下它來撥打電話時。但是當用戶按下文本時,什麼也沒有發生......這可能嗎?這是我的代碼:在列表中添加一個按鈕查看
public class museum extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.museum);
ListView list = (ListView) findViewById(R.id.list);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("name", "Archaeological Museum of Chania");
map.put("address", "Chalidon 21 , Chania");
mylist.add(map);
map = new HashMap<String, String>();
map.put("name", "Byzantine Museum");
map.put("address", "Theotokopoulou 82 , Chania");
mylist.add(map);
// ...
ListAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.row_museum,
new String[] {"name", "address"}, new int[] {R.id.TextView01, R.id.TextView02});
list.setAdapter(mSchedule);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
switch(position)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
}
});
}
}
你可以使用自定義適配器... – 2011-05-02 11:25:11