How to restrict this function from execution in android? Please help
- by andyfan
This code is present in one of this activity. I want to restrict addJoke() function from executing if the String variable new_joke is null, has no text or contains just spaces.
Here is code
protected void initAddJokeListeners() {
// TODO
m_vwJokeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
//Implement code to add a new joke here...
String new_joke=m_vwJokeEditText.getText().toString();
if(new_joke!=null&&new_joke!=""&&new_joke!=" ")
{
addJoke(new_joke);
}
}
});
}
I don't know why addJoke() function is getting executed even I don't enter any text in EditText field. Please help.