listview - Share button doesn't work in android -


i have listview , in baseadapter want have popup menu 1 of items "share" item when user clicks on share window/dialog popup:

this popup menu baseadapter of listview:

mviewholder.optionmenubutton.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              //creating instance of popupmenu             popupmenu popup = new popupmenu(context, mviewholder.optionmenubutton);             //inflating popup using xml file             popup.getmenuinflater().inflate(r.menu.share_menu, popup.getmenu());              //registering popup onmenuitemclicklistener             popup.setonmenuitemclicklistener(new popupmenu.onmenuitemclicklistener() {                 public boolean onmenuitemclick(menuitem item) {                     toast.maketext(context,                           "you clicked : " + item.gettitle(),                            toast.length_short).show();                      if (item.gettitle() == "share") {                          if (null == mainactivity) {                             mainactivity = (mainactivity) context;                         }                         mainactivity.shareaction();                         return true;                     }                     return false;                 }             });             popup.show();//showing popup menu          }     }); 

and how trying open share window/dialog, doesn't open share window/dialog toast saying clicked on "share" item of popup menu showing up:

public void shareaction() {     intent sharingintent = new intent(intent.action_send);     sharingintent.settype("text/plain");     string sharebody = "you have check out: " + "https://www.google.com/";     sharingintent.putextra(intent.extra_subject, "check out");     sharingintent.putextra(intent.extra_text, sharebody);     startactivity(intent.createchooser(sharingintent, "share via")); } 

the shareaction() method in mainactivity, , adapter baseadapter of listview , listview inside 1 of mainactivity's fragments.

also tried exect code of shareaction() method created , works fine in activity has no fragments, why it's weird doesn't work here...

remove code coding,

  if (null == mainactivity) {      mainactivity = (mainactivity) context;   } 

and match if condition this,

 if (item.gettitle().equals( "share")) {                     mainactivity.shareaction();                     return true;                 } 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -