android - Listview , open new activity onClick -



android - Listview , open new activity onClick -

hey i've looked hours trying find solution this, goal have listview when opens open activity. got able open activity when click how each list item open own activity? terribly sorry if question answered links found doesn't describe code doing [yes newbie :)]

this code im using

@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 toast textview text intent myintent = new intent(view.getcontext(), html_file.class); startactivityforresult(myintent, 0); } }); } }

lv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { // when clicked, show toast textview text if(position == 1) { //code specific first list item intent myintent = new intent(view.getcontext(), html_file1.class); startactivityforresult(myintent, 0); } if(position == 2) { //code specific 2nd list item intent myintent = new intent(view.getcontext(), html_file2.class); startactivityforresult(myintent, 0); } } });

android listview

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -