2014.1.28

来源:互联网 发布:sql注入绕过方法 编辑:程序博客网 时间:2024/06/06 02:26
1.
orderlist_lv=(ListView)this.findViewById(R.id.orderlist_lv);SimpleAdapter adapter=new SimpleAdapter(this, getData(), R.layout.orderlist_item, new String[]{"tv6","tv8"},new int[]{R.id.textView6,R.id.textView8});orderlist_lv.setAdapter(adapter);    //获取数据   private List<Map<String, Object>> getData() {List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();Map<String,Object> map=new HashMap<String,Object>();map.put("tv6", "张帅男");map.put("tv8", "顾德国");list.add(map);map=new HashMap<String,Object>();map.put("tv6", "张德江");map.put("tv8", "李富国");list.add(map);map=new HashMap<String,Object>();map.put("tv6", "王宝强");map.put("tv8", "张三");list.add(map);return list;}


2.
searchclient_list__lv.setOnItemClickListener(listener);//有名内部类实现private OnItemClickListener listener=new OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view,int position, long id) {Intent intent=new Intent(SearchClient_listActivity.this,SearchClient_listActivity_detail.class);startActivity(intent);}};

3.
/* * 创建popupwindow弹出框 * parent 是为了在此组件之下 */protected void createPopupWindow(View parent) {LayoutInflater inflater=LayoutInflater.from(this);View view=inflater.inflate(R.layout.orderlist_popup, null);// 创建PopupWindow对象 final PopupWindow pop = new PopupWindow(view, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true); pop.setBackgroundDrawable(new BitmapDrawable());  // 需要设置一下此参数,点击外边可消失 pop.setOutsideTouchable(true);  //设置点击窗口外边窗口消失pop.setFocusable(true);  // 设置此参数获得焦点,否则无法点击//pop.setAnimationStyle(R.style.PopupAnimation);if(pop.isShowing()){  //如果pop是有的pop.dismiss();    }else{//弹出框在组件之下pop.showAsDropDown(this.findViewById(R.id.orderlist_1));}}

4. 将popupwindow放在屏幕中间
vi=(RelativeLayout)this.findViewById(R.id.maintainlayout);  //主布局
pop.showAtLocation(vi, Gravity.CENTER, 0, 0);


0 0
原创粉丝点击