android - giving two functionality to a button based on conditions -
i have button , edit text. want work differently on pressing button depending on condition whether edittext have text or not? tried code given below it's not working.
string baseurl = null;(global variable)
code under button's onclick listener
baseurl = edittext.gettext().tostring(); if(!baseurl.isempty()){ body... }else if(baseurl.trim().length() == 0 || baseurl.isempty() || baseurl == null){ intent = new intent(urlfetcher.this, mainactivity.class); startactivity(i); }
if condition working else if not working app crashing on 2nd condition.
just use textutil library
string baseurl = edittext.gettext().tostring(); if(textutils.isempty(baseurl) { intent = new intent(urlfetcher.this, mainactivity.class); startactivity(i); } else { // body }
Comments
Post a Comment