
mListUsers = getUsers(); lvUsers = (ListVIEw) findVIEwByID(R.ID.lv_user); lvUsers.setAdapter(new listadapter(this, R.ID.lv_user, mListUsers)); lvUsers.setClickable(true); lvUsers.setonItemClickListener(new AdapterVIEw.OnItemClickListener() {@OverrIDe public voID onItemClick(AdapterVIEw<?> arg0, VIEw arg1, int position,long arg3) { // Todo auto-generated method stub Object o = lvUsers.getItemAtposition(position); UserBO obj = (UserBO) o; Toast.makeText(Select.this, "Record Selected= "+obj.getID()+" "+obj.getname()+" "+obj.getEmail()+" "+obj.getContact(), Toast.LENGTH_LONG).show(); Intent intent = new Intent(Select.this,Update.class); startActivity(intent); } });List_item.xml
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent" androID:padding="6px"androID:orIEntation="vertical"androID:layout_height="67px" androID:ID="@+ID/rlt_main"androID:background="#E0FFFF" androID:clickable="true"><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent" androID:orIEntation="horizontal"androID:layout_height="16px" androID:ID="@+ID/rlt_main"androID:background="#E0FFFF"><TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:ID="@+ID/tv_pID" androID:text="12" androID:layout_centerVertical="true" androID:textcolor="#E0FFFF" > </TextVIEw></linearLayout>select.xml<ListVIEw androID:layout_height="wrap_content" androID:ID="@+ID/lv_user" androID:layout_wIDth="fill_parent"androID:clickable="true">嗨,上面的代码是onclick ListvIEw项目选择.但是,当我单击ListvIEw中的项目时,发生了什么事情,而是我想调用update activity.我的代码有什么错误?如果有人想看一下XML布局的代码,那么让我知道..
解决方法:
ListVIEw lv = getListVIEw(); lv.setTextFilterEnabled(true); lv.setonItemClickListener(new OnItemClickListener() { public voID onItemClick(AdapterVIEw<?> parent, VIEw v,int position, long ID) { Toast.makeText(Context,"Selected item is "+ position, Toast.LENGTH_SHORT).show(); Intent i = new Intent(ListActivity.this, SecondActivity.class); ListActivity.this.startActivity(i); } } 总结 以上是内存溢出为你收集整理的android-Listview onclick如何调用另一个活动?全部内容,希望文章能够帮你解决android-Listview onclick如何调用另一个活动?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)