这是代码im使用
@OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] countrIEs = getResources().getStringArray(R.array.countrIEs_array); setlistadapter(new ArrayAdapter<String>(this,R.layout.newfile,countrIEs)); ListVIEw lv = getListVIEw(); lv.setTextFilterEnabled(true); lv.setonItemClickListener(new OnItemClickListener() { public voID onItemClick(AdapterVIEw<?> parent,VIEw vIEw,int position,long ID) { // When clicked,show a toast with the TextVIEw text Intent myIntent = new Intent(vIEw.getContext(),HTML_file.class); startActivityForResult(myIntent,0); } }); }}解决方法
lv.setonItemClickListener(new OnItemClickListener() { public voID onItemClick(AdapterVIEw<?> parent,long ID) { // When clicked,show a toast with the TextVIEw text if(position == 1) { //code specific to first List item Intent myIntent = new Intent(vIEw.getContext(),HTML_file1.class); startActivityForResult(myIntent,0); } if(position == 2) { //code specific to 2nd List item Intent myIntent = new Intent(vIEw.getContext(),HTML_file2.class); startActivityForResult(myIntent,0); } }});总结
以上是内存溢出为你收集整理的android – Listview,打开新的活动onClick全部内容,希望文章能够帮你解决android – Listview,打开新的活动onClick所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)