java - Sub Categories are not showing After Selecting Main Category - Android Studio -
i had wrote php script , sure working fine showing me following json output given below .....
json result
{"categories":[{"id":"1","name":"sub category 1"},{"id":"3","name":"sub category 2"}]}
but problem occurring sub categories not showing when select main caregory spinner.
java code :
public void getsubcategory(int cat_id) { string tag_json_arry = "json_object_req"; jsonobjectrequest req = new jsonobjectrequest(appconstants.getsubcategories(cat_id), new response.listener<jsonobject>() { @override public void onresponse(jsonobject response) { try { list<string> responselist = new arraylist<string>(); responselist.add("choose brand"); jsonarray jsonarray = response.getjsonarray("categories"); (int = 0; < jsonarray.length(); i++) { jsonobject jsonobject = new jsonobject(); jsonobject = jsonarray.getjsonobject(i); responselist.add(jsonobject.getstring("name")); model.categories model = new model.categories(); model.setid(jsonobject.getstring("id")); model.setname(jsonobject.getstring("name")); sub_categories.add(model); } refreshsubcategoryspinner(responselist); log.e("msg", response.tostring()); toast.maketext(getapplicationcontext(), "sucess", toast.length_long).show(); } catch (exception exp) { exp.printstacktrace(); toast.maketext(getapplicationcontext(), "" + exp.getmessage(), toast.length_long).show(); } } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror error) { toast.maketext(getapplicationcontext(), "error", toast.length_long).show(); log.e("zoyamsg", error.getmessage()); } }); appcontroller.getinstance().addtorequestqueue(req, tag_json_arry); }
Comments
Post a Comment