How do I when a button is pressed, activate a function only if a specific word has been typed in any position in an EditText? Thank you.
main.xml:
<EditText
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Digite aqui..."
android:id="@+id/searchfield"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Botão"
android:id="@+id/btn"/>
MainActivity.java:
Button btn = (Button)findViewById(R.id.btn);
final EditText search = (EditText)findViewById(R.id.searchfield);
go.setOnClickListener(new OnClickListener(){
public void onClick(View p1){
//O que devo colocar na condição if?
if(search.getText().toString()){
function();
}
}
});