Hi I am a Beginner in Android Development. I want to display data from xampp (phpmyadmin) in EditText if EditText value is not equal to ""(data from xampp!="") and if equal to ""(data from xampp==""), I want the user to type the value .{if the value is displayed it should not editable for user} I tried if..else
`
if(DepartStation_txt!=""){
DS.setText(DepartStation_txt);
DS.setEnabled(false);
}else {
DS.setText("Enter the Value");
DS.setEnabled(true);
}
` where DS is EditText DS=
(EditText) findViewById(R.id.DS);
in onCreate
Any functions that does this job and reason for this not working
Simply use methods of
Stringclass to compare strings. Now first of all you need to read text fromEditTextcontrol then you check if the string you want presents. For your case the sample code would be:Note that I used the
setHintmethod instead of thesetTextmethod since it is more suitable to instruct the users.