android - ListView .putExtra from DB Column -


i trying data db column contains url link; column name 'goto' w/in db. need pass onitemclick intent in listview load webpage new/next activity.

i don't know how function. if can please show code modifications explanation, helpful me learning. thnx!

revised:

i getting data passed method returning wrong row id. revised below activity. plz. thnx

within activities .oncreate (revised):

final listview lv = getlistview(); lv.settextfilterenabled(true);     lv.setonitemclicklistener(new onitemclicklistener() {         // @override         public void onitemclick(adapterview<?> a, view v, int position,long id)          {             object o = lv.getselecteditem();             //adapter_ac fullobject = (adapter_ac)o;              string url = "gotourl";             if(v != null) {                 textview tv = (textview)lv.findviewbyid(r.id.dummy);                 url = (string) tv.gettag();             }              toast.maketext(list_ac.this, "clicked: " +  url, toast.length_long).show();             intent = new intent(list_ac.this, docview.class);              i.putextra("url", url);             startactivity(i);         }     }); 

my adapter:

public class adapter_ac extends simplecursoradapter { private cursor datacursor;  private layoutinflater minflater;  public adapter_ac(context context, int layout, cursor datacursor,         string[] from, int[] to) {     super(context, layout, datacursor, from, to);     this.datacursor = datacursor;     minflater = layoutinflater.from(context); }  public view getview(int position, view convertview, viewgroup parent) {      viewholder holder;      if (convertview == null) {         convertview = minflater.inflate(r.layout.list_item, null);          holder = new viewholder();         holder.text1 = (textview) convertview.findviewbyid(r.id.label);         holder.text2 = (textview) convertview.findviewbyid(r.id.listtitle);         holder.text3 = (textview) convertview.findviewbyid(r.id.caption);          convertview.settag(holder);     } else {         holder = (viewholder) convertview.gettag();     }      datacursor.movetoposition(position);      int label_index = datacursor.getcolumnindex("label");     string label = datacursor.getstring(label_index);      int title_index = datacursor.getcolumnindex("title");     string title = datacursor.getstring(title_index);      int description_index = datacursor.getcolumnindex("description");     string description = datacursor.getstring(description_index);      int goto_index = datacursor.getcolumnindex("goto");     string gotourl = datacursor.getstring(goto_index);      holder.text1.settext(label);     holder.text2.settext(title);     holder.text3.settext(description);      return convertview; }  static class viewholder {     textview text1;     textview text2;     textview text3; } } 

try use settag:
@ first, set tag:

... holder.text3.settext(description); holder.text3.settag(gotourl); 

and when perform onclick event, tag:

public void onitemclick(adapterview<?> a, view v, int position,long id)  {     ...     string url = "";     if(v != null) {         textview tv = (textview)arg1.findviewbyid(r.id.caption);         url = (string) tv.gettag();     }     i.putextra("url", url);     startactivity(i); } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -