-1

这是我的 myadapterclass 的 getview 方法

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

    ApplicationInfo entry = ai.get(position);
    String str = insatllApps.get(position);
    System.out.println("Position============"+(insatllApps.get(position)));
    //Log.d("Check>>:","size>>"+insatllApps.size());
    convertView = mInflater.inflate(R.layout.list__button, null);
    t1=(TextView)convertView.findViewById(R.id.textView1);
    iv=(ImageView)convertView.findViewById(R.id.imageView1);
    tb1=(ToggleButton)convertView.findViewById(R.id.togal);
    tb1.setOnClickListener(this);
    tb1.setTag(pos);
    tb1.setTag(R.id.togal, str);

    iv.setImageDrawable(entry.loadIcon(mPackManager));


    t1.setText(str);


            return convertView;
}
4

1 回答 1

-1

好吧,这是可行的解决方案

     View row=null
    ApplicationInfo entry = ai.get(position);
        String str = insatllApps.get(position);
        System.out.println("Position============"+(insatllApps.get(position)));
        //Log.d("Check>>:","size>>"+insatllApps.size());
        row= mInflater.inflate(R.layout.list__button, null);
        t1=(TextView)row.findViewById(R.id.textView1);
        iv=(ImageView)row.findViewById(R.id.imageView1);
        tb1=(ToggleButton)row.findViewById(R.id.togal);
        tb1.setOnClickListener(this);
        tb1.setTag(pos);
        tb1.setTag(R.id.togal, str);

        iv.setImageDrawable(entry.loadIcon(mPackManager));


        t1.setText(str);

return row 

在 getView 方法中创建一个新视图

于 2013-03-02T07:22:12.607 回答