//为防止layout界面上的EditText在进入页面时就弹出输入法,隐藏软键盘
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
listView = (ListView)findViewById(R.id.group_discuss_list);
this.discussOnItemClickListener();
/**
* 评论列表被单击后的事件监听
*/
private void discussOnItemClickListener() {
//为评论的每一行添加单击事件
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view,int position, long id) {
//获得父贴的发帖人
Map posMap = discussList.get(position);
//设置pusername
pname = posMap.get("username");
//取得填写评论editText的实例
EditText disInputText = (EditText)findViewById(R.id.group_discuss);
disInputText.setHint("回复" + pname);
disInputText.requestFocus();
}
});
}
groupPopup = (ImageView) findViewById(R.id.group_discuss_popup);
groupPopup.setOnClickListener(titlePopupOnclick);
titlePopup = new TitlePopup(this, Utils.dip2px(this, 165), Utils.dip2px(this, 40));
titlePopup.addAction(new ActionItem(this, "赞", R.drawable.circle_praise));
titlePopup.addAction(new ActionItem(this, "评论",R.drawable.circle_comment));
titlePopup.setItemOnClickListener(this);
/**
* 单击评论按钮,弹出菜单的item click 监听
*/
@Override
public void onItemClick(ActionItem actionItem,int position) {
//position,0-赞;1-评论
switch(position){
case 0://赞
break;
case 1://评论
EditText disInputText = (EditText)findViewById(R.id.group_discuss);
disInputText.requestFocus();
break;
default:
break;
}
}
Map map = new HashMap();
//给map设置要显示的值
map.put("distime", DateUtils.formaterDate2YMDHm(new Date(System.currentTimeMillis())));
map.put("content", content);
//设置父贴的发帖人信息
map.put("puid", puid + "");
map.put("pname", pname);
//设置自己的信息
map.put("uid", uid + "");
map.put("username", username);
discussList.add(map);
ListLazyAdapter adapter = new ListLazyAdapter(this, discussList);
listView.setAdapter(adapter); //设置adapter
效果图如下:
本文示例源代码下载地址: