This is my code: here some edit texts are there.
public class MainActivity extends ActionBarActivity {
@InjectView(R.id.edt_fname) protected EditText account_fname;
@InjectView(R.id.edt_lnames) protected EditText account_lname;
@InjectView(R.id.edt_userid) protected EditText account_userid;
@InjectView(R.id.edt_pwd) protected EditText account_password;
@InjectView(R.id.edt_reenter) protected EditText account_reenter_pswd;
@InjectView(R.id.nxt_btn1) protected Button next_acct;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
next_acct.setEnabled(false);
if(( !account_fname.getText().toString().equals("")) &&
( !account_lname.getText().toString().equals("")) &&
( !account_userid.getText().toString().equals("")) &&
( !account_password.getText().toString().equals("")) &&
( !account_reenter_pswd.getText().toString().equals("")) )
{
next_acct.setEnabled(true);
next_acct.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), PersonalInfo.class));
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
} }
My aim is that when the fields are empty, then the submit button is disabled.
If all fields are filled with some text, then the submit button is enabled.
How can I do this?