我想在我的listView項目上放一個按鈕並撥打電話......但到目前爲止,我無法弄清楚如何將該數據分配給該按鈕操作,這裏是我的代碼...列表項本身不可點擊,只有按鈕是。我使用一個適配器從數組中獲取數據Android List View Button撥打電話
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder;
//Get the current location object
info lm = (info) getItem(position);
//Inflate the view
if(convertView==null)
{
convertView = dInflater.inflate(R.layout.dealbranch_layout, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.address);
holder.call = (Button) convertView.findViewById(R.id.call);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.name.setText(lm.getName());
holder.call.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent call = new Intent (Itent.ACTION_CALL);
/// No clue.. >,< /// /// lm.getPhone() should get the phone# for this row.
/// this action does not work /////
startActivity(call);
}
});
return convertView;
}
如果有人能指引我,那將會很棒。謝謝。
傳遞您在該適配器的構造函數中的電話號碼並呼叫該號碼。 – 2012-07-14 03:32:51
你能否詳述一下?非常感激=) – 2012-07-14 04:43:47
請參閱@ azgolfer的答案,正是我會建議你。 – 2012-07-14 05:16:43