android - Can,t access selectedCategoryId value outside the method -
im getting value selectedcategoryid defined in select method, in method initcat, getting 0 value selectedcategoryid, there way value 1 method method in same class, me out
here code
package com.panaceasoft.mypack.fragments; public class businessregisterfragment extends fragment implements view.onclicklistener { private arraylist < pcitydata > cityarraylist; private arraylist < psubcategorydata > subcatarraylist; private arraylist < pcitydata > citydataset; public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view = inflater.inflate(r.layout.fragment_business_register, container, false); initdata(); initui(); initcat(); return view; } private void initdata() {} public void initui() { citypopupcontainer = (linearlayout) view.findviewbyid(r.id.choose_city_container); citypopupcontainer.removeallviews(); catpopupcontainer = (linearlayout) view.findviewbyid(r.id.choose_cat_container); catpopupcontainer.removeallviews(); subcatpopupcontainer = (linearlayout) view.findviewbyid(r.id.choose_sub_cat_container); subcatpopupcontainer.removeallviews(); ppopupsingleselectview ppopupsingleselectview = new ppopupsingleselectview(getactivity(), selectcategorystring, globaldata.categorydatas, ""); ppopupsingleselectview.setonselectlistener(new selectlistener() { @override public void select(view view, int position, charsequence text) {} @override public void select(view view, int position, charsequence text, int id) { selectedcategoryid = id; selectedcategoryname = text.tostring(); } @override public void select(view view, int position, charsequence text, int id, float additionalprice) {} }); catpopupcontainer.addview(ppopupsingleselectview); imagetouplaod.setonclicklistener(this); buploadimage.setonclicklistener(this); bselectimage.setonclicklistener(this); btnregisterbusiness.setonclicklistener(new view.onclicklistener() {@ override public void onclick(view v) { inputmethodmanager imm = (inputmethodmanager) getactivity().getsystemservice(context.input_method_service); imm.hidesoftinputfromwindow(v.getwindowtoken(), 0); doregister(); } }); btncancelbusiness.setonclicklistener(new view.onclicklistener() {@ override public void onclick(view v) { docancel(); } }); prgdialog = new progressdialog(getactivity()); prgdialog.setmessage("please wait..."); prgdialog.setcancelable(false); } private void initcat() { requestsubcategory(config.app_api + config.get_subcat_by_cat + "?cat_id=" + selectedcategoryid); } }
try
private void initcat(int catid) { requestsubcategory(config.app_api + config.get_subcat_by_cat +"?cat_id="+catid); }
and call select()
method.
@override public void select(view view, int position, charsequence text, int id) { selectedcategoryid = id; selectedcategoryname = text.tostring(); initcat(id); }
Comments
Post a Comment