简体   繁体   中英

How to Refresh listview using getview of BaseAdapter on image clickEvent

public View getView(final int position, View v, ViewGroup parent) {

    Teami = (LayoutInflater) contextTeam
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    v = Teami.inflate(com.yellowflag.activity.R.layout.yf_login3_list_row,
            null);
    TextView txtzmarket = (TextView) v
            .findViewById(com.yellowflag.activity.R.id.txtzmarket);
    TextView txtzname = (TextView) v
            .findViewById(com.yellowflag.activity.R.id.txtzname);
    final ImageView img_nfl_favoriteactive = (ImageView) v
            .findViewById(com.yellowflag.activity.R.id.imgfavoriteactive);
    ImageView nfllist_image = (ImageView) v
            .findViewById(com.yellowflag.activity.R.id.list_image);

    String s = TeamList.get(position).getTeamID();
    String lower = s.toLowerCase();

    int image_id = contextTeam.getResources().getIdentifier(lower + "_25",
            "drawable", contextTeam.getPackageName());
    nfllist_image.setBackgroundResource(image_id);
    txtzmarket.setText(TeamList.get(position).getMarket());
    txtzname.setText(TeamList.get(position).getName());

    if (selected[position] == 1) {
        img_nfl_favoriteactive.setSelected(true);
    }

    img_nfl_favoriteactive.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            for (int i = 0; i < TeamList.size(); i++) {
                selected[i] = 0;
            }

            img_nfl_favoriteactive.setSelected(true);
            selected[position] = 1;





        }
    });

    return v;
}

I want to refresh listview using img_nfl_favoriteactive which is an image view of my rowview, Clickevent with getview method. how to refresh this using getview method clickevent using android please help me? Again, I also want to know that how can i implement the single item selector in this list view.

adapter.notifyDataSetChanged()

is used to refresh your adapter thereby refreshing your listview. Use this where ever you are interested to have

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM