【发布时间】:2014-02-20 06:21:49
【问题描述】:
我的列表视图中列出了许多列表项。
在具有 2 个按钮和一个文本视图的列表项中。
在这里我使用了以下代码。现在我的列表显示了编辑/删除按钮。如果我必须关注哪个列表项意味着该项目单独必须显示编辑/删除按钮。其他列表项不需要显示编辑/删除按钮。
我该怎么办?请检查一下并给我一个实现这部分的想法?
stafflist.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position,
long arg3) {
// TODO Auto-generated method stub
Button bPrevious = (Button)view.findViewById(R.id.view_staff);
bPrevious.setVisibility(View.VISIBLE);
Button bPlaying = (Button)view.findViewById(R.id.delete_staff);
bPlaying.setVisibility(View.VISIBLE);
}
});
现在,如果我从该列表中选择了任何项目,则意味着它正在显示编辑/删除按钮。之后,我从列表中选择了任何其他项目意味着该项目还显示编辑/删除按钮,而之前选择的项目也显示编辑/删除按钮。
但我想显示当前选中的项目只需要显示编辑/删除按钮?
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.manager_list_staff, null);
TextView staffname = (TextView)vi.findViewById(R.id.my_staffname);
TextView staff_empcode = (TextView)vi.findViewById(R.id.my_staffempcode);
LinearLayout editdelete = (LinearLayout)vi.findViewById(R.id.edit_delete);
final Button edit_staff = (Button)vi.findViewById(R.id.view_staff);
final Button delete_staff = (Button)vi.findViewById(R.id.delete_staff);
HashMap<String, String> Order = new HashMap<String, String>();
Order = data.get(position);
int temp = parent.getId()+1;
staff_id.setText(Order.get(Manager_List_Staff.TAG_STAFF_ID));
【问题讨论】:
-
表示单击列表项后要显示编辑/删除按钮??
-
使用带有编辑和删除按钮的上下文操作栏
-
我想单独显示当前选中的项目需要显示编辑/删除按钮?
标签: android show-hide android-button listadapter