/** * 初始化右上角弹框 */ 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