android - Populate ListView and their detail views with from multiple sqlite tables -


currently i'm searching solution populate listview content 3 different sqlite tables. when tapped, each listview item (row) should show according detailed view (activity), based on 1 of 3 xml layouts.

any suggestions?

edit:

currently solved 1 type of object/sqlite table. fetching content sqlite table arraylist , pass via putextra detail activity, handles setting texts/content.

the matching of listview entry , starting according detail view solved arraylist index matches listview index.

i'm not sure, if proper solution. guess isn't...

public void onitemclick(adapterview<?> parent, view view, int position, long id) {     intent typeone_details_intent = new intent(this, typeonedetailactivity.class);    typeone_result = new typeoneresult();    typeone_result = typeoneresult_arr.get(position);     typeone_details_intent.putextra("result", typeoneresult);    startactivity(typeone_details_intent); } 

how can solve add typetwodetails , better matching between listview , according detailview?

you can use custom adapter that can determine activity start, set custom row view, etc. 1 way, create row object interface, , check object type determine layout row , set things such onclick listener , activity launch.

quick example below:

public class customadapter extends baseadapter<listobjectinterface>{ ... listobjectinterface data[]; ....  public customadapter(context context, int layoutresourceid, listobjectinterface[] data) {     ... }  @override public view getview(int position, view convertview, viewgroup parent) {     view row = convertview;     ... /* things. such check if instance present, etc. */      listobjectinterface object = data[position];      if (object instanceof typea) {         row = inflater.inflate(layoutresourceida, parent, false);         ...         ... /* view objects , set button listener launch activity */     } else if (object instanceof typeb) {         row = inflater.inflate(layoutresourceidb, parent, false);         ...         ... /* view objects , set button listener launch activity b */     } ... /* etc */      ... /* more logic */      return row; } } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -