如何使用BaseAdapter的getview图像刷新列表视图clickEvent [英] How to Refresh listview using getview of BaseAdapter on image clickEvent

查看:89
本文介绍了如何使用BaseAdapter的getview图像刷新列表视图clickEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 公共查看getView(最终诠释的立场,观点V,父母的ViewGroup){    Teami =(LayoutInflater)contextTeam
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    V = Teami.inflate(com.yellowflag.activity.R.layout.yf_login3_list_row,
            空值);
    TextView的txtzmarket =(TextView的)V
            .findViewById(com.yellowflag.activity.R.id.txtzmarket);
    TextView的txtzname =(TextView的)V
            .findViewById(com.yellowflag.activity.R.id.txtzname);
    最后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);    字符串s = TeamList.get(位置).getTeamID();
    串低级= s.toLowerCase();    INT image_id = contextTeam.getResources()则getIdentifier(下+_25
            可拉伸,contextTeam.getPackageName());
    nfllist_image.setBackgroundResource(image_id);
    txtzmarket.setText(TeamList.get(位置).getMarket());
    txtzname.setText(TeamList.get(位置).getName());    如果(选择[​​位置] == 1){
        img_nfl_favoriteactive.setSelected(真);
    }    img_nfl_favoriteactive.setOnClickListener(新OnClickListener(){        @覆盖
        公共无效的onClick(视图v){            的for(int i = 0; I< TeamList.size();我++){
                选择了[I] = 0;
            }            img_nfl_favoriteactive.setSelected(真);
            选择[位置] = 1;        }
    });    返回伏;
}

我要刷新使用img_nfl_favoriteactive这是我rowview,Clickevent与getview方法的图像视图列表视图。
如何使用Android的请帮我刷新此使用getview方法clickevent?
同样,我也想知道,我怎样才能实现这个列表视图中的单个项目的选择。


解决方案

  

adapter.notifyDataSetChanged()


用于刷新您的适配器,从而刷新了您的列表视图。
使用这个在任何你有兴趣有

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

这篇关于如何使用BaseAdapter的getview图像刷新列表视图clickEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆