Android 如何通过长按list弹出操作选项

来源:互联网 发布:郝斌c语言180视频教程 编辑:程序博客网 时间:2024/05/14 08:22
protected void onListItemClick(int position) {final int pos = position;
AlertDialog dlg = new AlertDialog.Builder(this).setTitle(R.string.team_change).setItems(items, new OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {if (which == 0) {sendMSG(pos);} else if (which == 1) {changeIcon(pos);} else if (which == 2) {if (isLeader) {changeLeader(pos);}}}}).create();dlg.show();
}
pos是点击弹出的列表的行号,再通过对pos的辨别分别作不做的操作,初学安卓不久,一点点的小技术使用都是一个进步,坚持下去就是胜利!
原创粉丝点击