android - Get data from database and share the content -


i have listactivity data mysql , insert them inside listview ... have sharemethod need receive data listview sharing .. im sorry think have put whole activity here ..

“thanks in advance”

listactivity.java

public class listactivity extends appcompatactivity implements asyncresponse, adapterview.onitemclicklistener {   public static final int notification_id = 1;  final string log = "listactivity";  private arraylist<product> productlist; private listview lvproduct; private fundapter<product> adapter;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_list);      imageloader.getinstance().init(uilconfig.config(listactivity.this));      postresponseasynctask taskread = new postresponseasynctask(listactivity.this, this);       //taskread.execute("http://10.0.3.2/customer/product.php");      taskread.execute("http://symphonyrecords.6te.net/product.php");      lvproduct = (listview)findviewbyid(r.id.lvproduct);      registerforcontextmenu(lvproduct);   }//oncreate   @override public void processfinish(string s) {     productlist = new jsonconverter<product>().toarraylist(s, product.class);      binddictionary<product> dict = new binddictionary<product>();     dict.addstringfield(r.id.tvname, new stringextractor<product>() {         @override         public string getstringvalue(product product, int position) {             return product.name;         }     });      dict.addstringfield(r.id.tvdescription, new stringextractor<product>() {         @override         public string getstringvalue(product product, int position) {             return product.description;         }     });       dict.addstringfield(r.id.tvdate, new stringextractor<product>() {         @override         public string getstringvalue(product product, int position) {             return "" + product.date;         }     });       dict.addstringfield(r.id.tvqty, new stringextractor<product>() {         @override         public string getstringvalue(product product, int position) {             return "" + product.qty;         }     });       dict.adddynamicimagefield(r.id.ivimage,             new stringextractor<product>() {                 @override                 public string getstringvalue(product product, int position) {                     return product.image_url;                 }             }, new dynamicimageloader() {                 @override                 public void loadimage(string url, imageview imageview) {                                  imageloader.getinstance().displayimage(url, imageview);                     imageview.setpadding(0, 0, 0, 0);                     imageview.setadjustviewbounds(true);                 }             });      adapter = new fundapter<>(             listactivity.this, productlist, r.layout.layout_list, dict);       lvproduct.setadapter(adapter);     lvproduct.setonitemclicklistener(this); }  @override public void onitemclick(adapterview<?> parent, view view, int position, long id) {     product selectedproduct = productlist.get(position);     intent in = new intent(listactivity.this, detailactivity.class);     in.putextra("product", (serializable) selectedproduct);     startactivity(in);   }     //this share method public void sharemethod(view view1) {      intent sharingintent = new intent(android.content.intent.action_send);      sharingintent.settype("text/plain");     string sharebody = "share content body";     sharingintent.putextra(android.content.intent.extra_subject, "subject here");     sharingintent.putextra(android.content.intent.extra_text,sharebody);     startactivity(intent.createchooser(sharingintent, "share via"));  }    } 

when list item clicked, can form instance string variable, , fill in data product. in sharemethod, can add string sharestr , share. example,

public class listactivity..{        private string msharestr;            ...       <  *when list item clicked fill in*      msharestr = string.format("%s - %s %s : %s", name, description, date, qty);  >         public void sharemethod(view view1)       {           ...           sharingintent.putextra(intent.extra_text, msharestr);       }   } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -