Here is my code. In this code I give some values to edittext, and it passes to the next page. If I didn't give any value to that edittext, it gets "FORCE CLOSED". I want to set edittext in such a way that if I didn't give any values, it must show a toast that says "give some value and submit".
Here is the code...
Button damage = (Button) findViewById(R.id.btn_damage_reason);
damage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Unloading.this, DamageReason.class);
i.putExtra("count", dmg_cyl_recvd.getText().toString());
startActivity(i);
}
});
Use this
String editTextString = dmg_cyl_recvd.getText().toString();
if( editTextString != null && editTextString.length() > 0)
{
//go to next view
}
else {
// show toast
}