How could i pass the value from base adapter to ac

2019-03-05 23:06发布

问题:

I am working in one app where i need to pass the value from base adapter class to activity

here is the snippet code:

public View getView(int position, View convertView, ViewGroup parent) {


            vi=convertView;


            if(convertView==null){
                vi = LayoutInflater.from(parent.getContext()).inflate(R.layout.screen, null);

               position_pin = position;

              Holder.images=(ImageView) vi.findViewById(R.id.image);
              Holder.textview=(TextView) vi.findViewById(R.id.name);



             Holder.images.setImageResource(imageIds[position]);
           Holder.text.setText(name);//here name is String 

             vi.setTag(Holder);   

            }

                        return vi;
            }

Here i am getting the image id position:

 Holder.images.setImageResource(imageIds[position]);

how could i pass the imageIds position to activity Thanks !!

回答1:

U can use below code inside ur activity

 for(int i=0;i<list.getCount();i++)
  {
   //here u can add i values to an array for storing positions or do anything else u want
  }