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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -