您的位置:首页 > 其它

2014.1.28

2014-01-28 13:45 183 查看
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() {

@Override
public 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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: