2

I have a class for custom ArrayAdapter for my ListView, below is the code.

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;
    }
}

Look at this context.startActivityForResult(intent, PICK_CONTACT); how can i define my onActivityResult in my customArrayAdapter?

4

1 に答える 1

0

onActivityResult(int requestCode, int resultCode, Intent data)は、どの Java クラスにも対応しないアクティビティ クラス メソッドです。

Androidアクティビティ自体でのみ機能します。

于 2013-02-03T05:09:01.897 に答える