【发布时间】:2016-01-03 17:04:06
【问题描述】:
我想为自定义列表视图中的每个联系人添加通话选项。我这样做了。我有一个图像视图,单击时我需要拨打电话。显示的错误是“未定义类型 new View.OnClickListener() 的方法 startActivity(View)”
public View getView(int position, View convertView, ViewGroup arg2) {
listRowAuto autoListItems = autoList.get(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.item_auto, null);
}
TextView tvName = (TextView) convertView.findViewById(R.id.auto_tv1);
tvName.setText(autoListItems.getName());
TextView tvPhone = (TextView) convertView.findViewById(R.id.auto_tv2);
tvPhone.setText(autoListItems.getPhone());
ImageView autoCall=(ImageView) convertView.findViewById(R.id.auto_call);
autoCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view1) {
// TODO Auto-generated method stub
view1 = new Intent("android.intent.action.CALL");
view1.setData(Uri.parse((new StringBuilder()).append("tel:").append(autoListItems.getPhone()).toString()));
startActivity(view1);
}
});
return convertView;
}
【问题讨论】:
标签: android listview android-intent