android - Why value not same even call same variable -
this question has answer here:
- android: converting string int 7 answers
//global getdatabasechart(); adddata(); public void adddata() { int a; = profile.gettotalbelum(); log.d("aa",""+a); final float[] ydata = {a}; ...... } public void getdatabasechart(){ //creating string request log.d("masuktak","masuktak"); stringrequest stringrequest = new stringrequest(request.method.post, config.url_web + "a.php", new response.listener<string>() { @override public void onresponse(string response) { // hidepdialog(); try { log.d("tgksini", response); jsonobject json = new jsonobject(response); int success = json.getint("success"); if (success == 1) { user = json.getjsonarray("user"); (int = 0; < user.length(); i++) { jsonobject obj = user.getjsonobject(i); profile = new profileuser(); profile.settotalbelum(obj.getint("belum")); log.d("belumb",string.valueof(profile.gettotalbelum())); } abc = profile.gettotalbelum(); log.d("abccc", string.valueof(abc)); } else { log.d("data2 ", "no user"); } ...............
this code .. change code .. direct integer value .. when see logcat .. check log.d abccc .. value abc = 2 ... check log.d aa value = 0 ...
how solve ? please me.
if try parse integer.
check before parsing. or handle exception properly. example:
try{ int = integer.parseint(profile.gettotalbelum()); }catch(numberformatexception ex){ // handle exception
... }
Comments
Post a Comment