一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

android-BaseAdapter中的notifyDataSetChanged()

 印度阿三17 2019-10-31

這是我的代碼,在這里我試圖從Arraylist中刪除該項(xiàng)目,并嘗試使用notifyDataSetChanged更新布局項(xiàng)目.

public class GroupContactListingAdapter extends BaseAdapter {

    private LayoutInflater mInflater;
    private ArrayList<ContactListDto> groupListDto = new ArrayList<ContactListDto>();
    private Activity context;
    public static ArrayList<String> selectList;

    @Override
    public void notifyDataSetChanged() {
        super.notifyDataSetChanged();
    }

    /**
     * Assigning the parameter
     * 
     * @param mContext1
     *            Getting the context of the class
     * @param contactList
     *            list to be display
     * @param value
     *            if 0 all, if 1 unblocked and 2 blocked
     * @param isContactList
     *            if 1 then contact list and if 0 search contact list
     */
    public GroupContactListingAdapter(Activity mContext1,
            ArrayList<ContactListDto> contactList) {
        this.context = mContext1;
        this.mInflater = (LayoutInflater) mContext1
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (this.groupListDto != null) {
            this.groupListDto.clear();
        }
        this.groupListDto = contactList;
        selectList = new ArrayList<String>();
    }

    @Override
    public int getCount() {
        return groupListDto.size();
    }

    @Override
    public Object getItem(int position) {
        return groupListDto.get(position);
    }

    @Override
    public long getItemId(int arg0) {
        return arg0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup arg2) {
        final ViewHolder viewHolder;
        if (convertView == null) {

            convertView = mInflater.inflate(R.layout.group_listing_item, null);
            viewHolder = new ViewHolder();
            viewHolder.nameTextView = (TextView) convertView
                    .findViewById(R.id.group_name);
            viewHolder.relative = (RelativeLayout) convertView
                    .findViewById(R.id.group_layout);
            viewHolder.deleteContacts = (Button) convertView
                    .findViewById(R.id.btn_group_contact_delete);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.deleteContacts.setVisibility(View.VISIBLE);
        viewHolder.deleteContacts
                .setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        Helper.printLogD(" deleting position is "   position);
                        selectList.add(groupListDto.get(position)
                                .getContactId());
                        groupListDto.remove(groupListDto.get(position));

                        notifyDataSetChanged();


                    }
                });

        viewHolder.nameTextView.setText(groupListDto.get(position)
                .getContactFullName());
        if (position % 2 == 0) {
            viewHolder.relative.setBackgroundColor(context.getResources()
                    .getColor(R.color.white));
        } else {
            viewHolder.relative.setBackgroundColor(context.getResources()
                    .getColor(R.color.list_even_color));
        }
        return convertView;
    }

發(fā)生以下錯誤

12-18 11:43:01.895: E/ListView(24434): null
12-18 11:43:01.895: E/ListView(24434): java.lang.NullPointerException
12-18 11:43:01.895: E/ListView(24434):  at com.hazemedia.stewdent.client.android.ui.adapter.GroupContactListingAdapter$ViewHolder.access$4(GroupContactListingAdapter.java:133)
12-18 11:43:01.895: E/ListView(24434):  at com.hazemedia.stewdent.client.android.ui.adapter.GroupContactListingAdapter.getView(GroupContactListingAdapter.java:94)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.AbsListView.obtainView(AbsListView.java:1428)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.ListView.makeAndAddView(ListView.java:1801)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.ListView.fillSpecific(ListView.java:1339)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.ListView.layoutChildren(ListView.java:1625)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.AbsListView.onLayout(AbsListView.java:1279)
12-18 11:43:01.895: E/ListView(24434):  at android.view.View.layout(View.java:7321)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
12-18 11:43:01.895: E/ListView(24434):  at android.view.View.layout(View.java:7321)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-18 11:43:01.895: E/ListView(24434):  at android.view.View.layout(View.java:7321)
12-18 11:43:01.895: E/ListView(24434):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-18 11:43:01.895: E/ListView(24434):  at android.view.View.layout(View.java:7321)
12-18 11:43:01.895: E/ListView(24434):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
12-18 11:43:01.895: E/ListView(24434):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
12-18 11:43:01.895: E/ListView(24434):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-18 11:43:01.895: E/ListView(24434):  at android.os.Looper.loop(Looper.java:150)
12-18 11:43:01.895: E/ListView(24434):  at android.app.ActivityThread.main(ActivityThread.java:4389)
12-18 11:43:01.895: E/ListView(24434):  at java.lang.reflect.Method.invokeNative(Native Method)
12-18 11:43:01.895: E/ListView(24434):  at java.lang.reflect.Method.invoke(Method.java:507)
12-18 11:43:01.895: E/ListView(24434):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
12-18 11:43:01.895: E/ListView(24434):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
12-18 11:43:01.895: E/ListView(24434):  at dalvik.system.NativeStart.main(Native Method)

解決方法:

出現(xiàn)此問題是因?yàn)槲覜]有在convertView實(shí)例中標(biāo)記viewHolder.

convertView .setTag(viewHolder);
來源:https://www./content-4-538751.html

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    午夜福利视频日本一区| 午夜视频免费观看成人| 国产超薄黑色肉色丝袜| 精品午夜福利无人区乱码| 99久免费精品视频在线观| 高清免费在线不卡视频| 日韩女优视频国产一区| 亚洲欧美日本国产不卡| 日韩精品区欧美在线一区| 又黄又色又爽又免费的视频| 人人爽夜夜爽夜夜爽精品视频| 欧洲日本亚洲一区二区| 成人日韩视频中文字幕| 国产精品亚洲综合色区韩国 | 永久福利盒子日韩日韩| 国产在线不卡中文字幕| 国产精品久久三级精品| 激情五月激情婷婷丁香| 日本人妻精品中文字幕不卡乱码| 欧美不雅视频午夜福利| 在线日韩欧美国产自拍| 国产精品一区二区视频成人| 亚洲最大福利在线观看| 欧美精品二区中文乱码字幕高清| 激情图日韩精品中文字幕| 色婷婷国产熟妇人妻露脸| 免费午夜福利不卡片在线 视频| 国产午夜精品在线免费看| 亚洲另类欧美综合日韩精品| 国产精品成人又粗又长又爽| 久一视频这里只有精品| 国产性色精品福利在线观看| 色偷偷偷拍视频在线观看| 高清一区二区三区四区五区| 欧美一级特黄大片做受大屁股| 婷婷激情五月天丁香社区| 丁香六月啪啪激情综合区| 欧美日韩黑人免费观看| 在线欧美精品二区三区| 亚洲精品国产美女久久久99| 高清一区二区三区不卡免费|