android中PopupWindow和ListView一起使用时,bug

/**
 * 初始化右上角弹框
 */
private void initPopupWindow() {
    tipcontainer = (LinearLayout) View.inflate(this, R.layout.tiplayout, null);
    ListView listView = (ListView) tipcontainer.findViewById(R.id.tip_lsit);
    tipWindow = new PopupWindow(tipcontainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    tipWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_drop_top_norm));
    tipWindow.setOutsideTouchable(true);
    tipWindow.setTouchable(true);
    //在Android 4.1 和 4.2 系统中,必须进行该设置,获取 PopupWindow 焦点
    //后续版本不需要进行该项设置  
    tipWindow.setFocusable(true);
    moreMenu.setImageResource(R.drawable.nav_btn_more);

    if (!isOfficialCustomer) {
        if (!addlist.contains("transuc"))
            addlist.add(0, "transuc");
        }else{
            addlist.remove("transuc");
        }
    if (addlist.size() != 0) {
        moreMenu.setClickable(true);
        moreMenu.setVisibility(View.VISIBLE);
    }
    adapter = new BaseAdapter() {
        @Override
        public int getCount() {
            return addlist.size();
        }

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

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

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            convertView = View.inflate(CustomerDetailActivity.this, R.layout.new_rod_item, null);
            ImageView image = (ImageView) convertView.findViewById(R.id.rod_image);
            TextView name = (TextView) convertView.findViewById(R.id.rod_name);
            if (addlist.get(position) instanceof String) {
                image.setImageResource(R.drawable.list_drop_ic_guest);
                name.setText("转正式客户");
            } else {
                RelateShowItem item = (RelateShowItem) addlist.get(position);
                if ("Lead".equals(item.getRelatetype())) {
                    image.setImageResource(R.drawable.list_drop_ic_clues);
                } else if ("BNSOportunity".equals(item.getRelatetype())) {
                    image.setImageResource(R.drawable.list_drop_ic_opportunities);
                } else if ("Contact".equals(item.getRelatetype())) {
                    image.setImageResource(R.drawable.list_drop_ic_contacts);
                } else if ("Action".equals(item.getRelatetype())) {
                    image.setImageResource(R.drawable.list_drop_ic_action);
                } else if ("CustomerEquipment".equals(item.getRelatetype())) {
                    image.setImageResource(R.drawable.list_drop_ic_equip);
                } else if ("CompeteOrder".equals(item.getRelatetype())){
                    image.setImageResource(R.drawable.list_drop_ic_compoduct);
                } else if ("SalesOrder".equals(item.getRelatetype())){
                    image.setImageResource(R.drawable.list_drop_ic_orders);
                }
                name.setText("新增"+item.getRelatename());
            }
            return convertView;
        }
    };
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (addlist.get(position) instanceof String) {
                tipWindow.dismiss();
                handleTransBtn();
            } else {
                final RelateShowItem item = (RelateShowItem) addlist.get(position);
                if (item.getRelatetype().equals("Lead")) {
                    clicksubtype = "Lead";
                    nextobjectType = "2";
                    clickAddBtn(item);
                }// 行动
                else if (item.getRelatetype().equals("Action")) {
                    clicksubtype = "Action";
                    nextobjectType = "5";
                    clickAddBtn(item);
                }// 商机
                else if (item.getRelatetype().equals("BNSOportunity")) {
                    clicksubtype = "BNSOportunity";
                    nextobjectType = "4";
                    clickAddBtn(item);
                }// 联系人
                else if (item.getRelatetype().equals("Contact")) {
                    if (objectType.equals("4")) {
                        Intent i = new Intent();
                        i.putExtra("id", objectid);
                        i.putExtra("action", "add");
                        i.putExtra("objectType", "3");
                        i.setClass(CustomerDetailActivity.this,
                                RelateSelectObjList.class);
                        startActivityForResult(i, REQUEST_CODE_BO_CONTACT);
                    } else {
                        clicksubtype = "Contact";
                        nextobjectType = "3";
                        clickAddBtn(item);
                    }
                }//设备
                else if (item.getRelatetype().equals("CustomerEquipment")){
                    clicksubtype = "CustomerEquipment";
                    nextobjectType = "12";
                    clickAddBtn(item);
                }//竞品
                else if (item.getRelatetype().equals("CompeteOrder")){
                    clicksubtype = "CompeteOrder";
                    nextobjectType = "13";
                    clickAddBtn(item);
                }
            }
        }
    });

}

转载于:https://my.oschina.net/u/2518026/blog/756374

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值