java - Why this if statement is being skipped? -
can anyway tell me why following if statement being skipped? want check if malphabetcode contains 0-9 literal, not 0 9.
// check if alphabet code numeric if (malphabetcode.equals("0-9")){ malphabetcode = "-"; }
here whole code:
public void onitemclick(adapterview<?> parent, view view, int position, long id) { if (parent.getid() == r.id.lv_gl_content) { // store data pass intent mintent = new intent(this, achlist.class); mintent.putextra("mpageurl", mgamelist.get(position).getitempageurl()); mintent.putextra("mgametitle", mgamelist.get(position).gettitle()); // start activity , page animation startactivity(mintent); mpagetrans.slidein(); } else if (parent.getid() == r.id.lv_alphabet_content) { // alphabet code string malphabetcode = parent.getadapter().getitem(position).tostring().tolowercase(); // check if alphabet code numeric if (malphabetcode.equals("0-9")){ malphabetcode = "-"; } // build page url mgamelisturl = mgamelisturl.substring(0, (mgamelisturl.length() - 2) ) + malphabetcode + "/"; malphabetmenu.setitemchecked(position, true); // close browsing menu mslidingpane.closepane(); // make network request mstringrequest = new stringrequest(request.method.get, mgamelisturl, onsuccess(), onerror()); mrequestqueue.add(mstringrequest); } }
and here debugger saying malphabetcode contains before hitting if statement:
my error here in strings.xml file:
<!-- strings of arrays --> <string-array name="slide_menu_alphabet"> <item>0–9</item>
i had changed item 0-9 0 – ;9 (spaced numbers show) androidstudio ide subjected , @user1873880 , david cesarino, changed 0 - ;9 (spaced numbers show) , works great.
thanks help.
the problem '-' character in code in fact has integer number 45, while in debugger it's 8211, mean different character. can verify via logs, try see value (int) '-'
.
Comments
Post a Comment