i have question: can use inner class variable instantiated in method in method?
public void onitemclick(adapterview<?> a, android.view.view v, int position, long id) { // todo auto-generated method stub int diffindays=0; object o = lv1.getitematposition(position); masina m = (masina) o; toast.maketext(mainactivity.this, "selected :" + " " + m, toast.length_long).show(); string data=((masina) image_details.get(position)).getdata_fabr(); calendar c=calendar.getinstance(); simpledateformat df=new simpledateformat("dd/mm/yyyy"); string currdata=df.format(c.gettime()); try { date obj=df.parse(data); date obj2=df.parse(currdata); diffindays = (int) ((obj2.gettime() - obj.gettime())/ (1000 * 60 * 60 * 24)); } catch (parseexception e) { // todo auto-generated catch block e.printstacktrace(); } int years=diffindays/365; int days=diffindays%365; poz=position; mar=((masina) image_details.get(poz)).getmarca(); mod=((masina) image_details.get(poz)).getmodel(); nr=((masina) image_details.get(poz)).getnr_inm(); date=((masina) image_details.get(poz)).getdata_fabr(); afisare.settext("numar inmatriculare: "+((masina) image_details.get(position)).getnr_inm()); afisare.append("\nvarsta masina: "+years+" ani "+days+" zile"); } }); } public void oncreatecontextmenu(contextmenu menu, view v, contextmenuinfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.context_menu, menu); } public boolean oncontextitemselected(menuitem item) { adaptercontextmenuinfo info = (adaptercontextmenuinfo) item.getmenuinfo(); switch(item.getitemid()) { case r.id.edit: toast.maketext(this, "ai ales: " + getresources().getstring(r.string.editeaza), toast.length_short).show(); intent startnewact=new intent(mainactivity.this, editactivity.class); startnewact.putextra("marca",mar); startnewact.putextra("model",mod); startnewact.putextra("nr.inm",nr); startnewact.putextra("data",date); startactivityforresult(startnewact,0); return true;
i want use vb mar in method oncontextitemselected. help, please. thank much.
u can initialized vb mar public static in method.
Comments
Post a Comment