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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -