由网友(癮男)分享简介:我有这样的低于code访问ListView项值转换成字符串,并在警报显示呢?的ListView拍= getListView();shot.setOnItemClickListener(本);公共无效onItemClick(适配器视图<>为arg0,查看ARG1,INT ARG2,长ARG3){字符串s =...![Android ListView Item滑动删除的效果问题](https://p.xsw88.cn/allimgs/daicuo/20230907/5393.png)
我有这样的低于code访问ListView项值转换成字符串,并在警报显示呢?
的ListView拍= getListView();
shot.setOnItemClickListener(本);
公共无效onItemClick(适配器视图<>为arg0,查看ARG1,INT ARG2,长ARG3){
字符串s = arg1.getContext()的toString()。
AlertDialog.Builder alertbox =新AlertDialog.Builder(本);
//设置为显示该消息
alertbox.setMessage(S) - .show();
}
解决方案
也许这个例子可以帮助你。
lv.setOnItemClickListener(新OnItemClickListener(){
公共无效onItemClick(适配器视图<>母公司视图中查看,
INT位置,长的id){
//单击时,显示出与TextView的文字敬酒
Toast.makeText(getApplicationContext(),((TextView的)视图).getText()
Toast.LENGTH_SHORT).show();
}
});
http://developer.android.com/intl/zh-TW/resources/tutorials/views/hello-listview.html
![Android ListView Item滑动删除的效果问题](https://p.xsw88.cn/allimgs/daicuo/20230907/5393.png)
I have this below code access the ListView item value into string and display it in alert?
ListView shot = getListView();
shot.setOnItemClickListener(this);
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
String S = arg1.getContext().toString();
AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
// set the message to display
alertbox.setMessage(S).show();
}
解决方案
maybe this example will help you
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();
}
});
http://developer.android.com/intl/zh-TW/resources/tutorials/views/hello-listview.html
相关推荐
最新文章