android - Launch a Dialog Fragment on button click from a custom base adapter>getView [IMG INCLUDED] -


alright have list(which fragment dialog) displays users friends , each item in list has button(labeled friends in picture) , when users click button id display fragment dialog displays options interacting user(friend request, block, send private message ect...) problem button , onclick listener implemented via overriding listview adapters getview method , create fragmentdialog requires access fragment manager. there way make work?

edit: cannot post actual code project , ive attached simplified base adapter w. onclicklistener should make clear im trying . cannot access fragmentmanager base adapter class make dialog fragment possible

lazyadapter.java package com.example.androidhive;  import java.util.arraylist; import java.util.hashmap;  import android.app.activity; import android.content.context; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.baseadapter; import android.widget.imageview; import android.widget.textview;  public class lazyadapter extends baseadapter {      private activity activity;     private arraylist<hashmap<string, string>> data;     private static layoutinflater inflater=null;     public imageloader imageloader;      public lazyadapter(activity a, arraylist<hashmap<string, string>> d) {         activity = a;         data=d;         inflater = (layoutinflater)activity.getsystemservice(context.layout_inflater_service);         imageloader=new imageloader(activity.getapplicationcontext());     }      public int getcount() {         return data.size();     }      public object getitem(int position) {         return position;     }      public long getitemid(int position) {         return position;     }      public view getview(int position, view convertview, viewgroup parent) {         view vi=convertview;         if(convertview==null)             vi = inflater.inflate(r.layout.list_row, null);          button requestbtn = (button)vi.findviewbyid(r.id.title); // title          hashmap<string, string> song = new hashmap<string, string>();         song = data.get(position);          // setting values in listview         title.settext(song.get(customizedlistview.key_title));         artist.settext(song.get(customizedlistview.key_artist));         duration.settext(song.get(customizedlistview.key_duration));         imageloader.displayimage(song.get(customizedlistview.key_thumb_url), thumb_image);          requestbtn.setonclicklistener(new myonclicklistener(position));         return vi;     }          public class myonclicklistener implements onclicklistener{      private int position;   private string clicked_uid;   public myonclicklistener(int position){       this.position=position;      }   @override   public void onclick(view v) {       //this im trying put fragment dialog          fragmentmanager fm = tabhostfragmentactivity.this.getsupportfragmentmanager();         friendsfamiliarsdialog friendsdialog = new friendsfamiliarsdialog().newinstance(tabhostfragmentactivity.profile_uid,"friends");         friendsdialog.show(fm, "friendsdialog");        }      } } 

listview fragment dialog getview android

when create lazyadapter pass in view adapter created or parent fragment or activity, , in onclick method use call function on fragment or activity show dialog fragment, remember adapter class should sending message through function calls ui components interesting showing dialog fragments


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -