我的 ListView 有一个用于自定义 ArrayAdapter 的类,下面是代码。
public class CustomArrayAdapterForProduct extends ArrayAdapter<ProductClass>
{
private final Activity context;
public final ArrayList<ProductClass> products;
private static final int PICK_CONTACT = 1;
public CustomArrayAdapterForProduct(Activity context, ArrayList<ProductClass> products)
{
super(context, R.layout.product, products);
this.context = context;
this.products = products;
}
static class ViewHolder {
protected TextView name;
protected Button share;
protected Button call;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View view = null;
LayoutInflater inflator = context.getLayoutInflater();
view = inflator.inflate(R.layout.product, parent,false);
final ViewHolder viewHolder = new ViewHolder();
final ProductClass file = products.get(position);
viewHolder.name = (TextView) view.findViewById(R.id.name);
viewHolder.share = (Button) view.findViewById(R.id.videoView);
viewHolder.call = (Button) view.findViewById(R.id.videoView);
viewHolder.share.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
context.startActivityForResult(intent, PICK_CONTACT);
}
});
viewHolder.name.setText(file.name.toString());
view.setTag(viewHolder);
return view;
}
}
看看这个context.startActivityForResult(intent, PICK_CONTACT);
我如何onActivityResult
在我的 customArrayAdapter 中定义我的?