Reputation: 3
I am not sure if it is even possible but if it is I would appreciate your help! I need to change the textHint depending which radioButton is checked Radio Buttons. For example, I want the editText Hint to display "Miles" if the US radioButon is checked; and when the radioButton Metric is checked I want the textHint to display "Kilometers."
I attempted to solve this multiple time but constantly fail.
Tanks ahead of time!
Upvotes: 0
Views: 843
Reputation: 14810
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
// checkedId is the RadioButton selected
switch (checkedId) {
case R.id.radioButtonUS:
Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_LONG).show();
Distance.setHint("Miles");
break;
case R.id.radioButtonMetric:
Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_LONG).show();
Distance.setHint("Kilometers");
break;
}
}
});
Upvotes: 2
Reputation: 779
You can use setHint(hint);
on your EditText to change the Hint.
You can use a listener on your radioButton to detect when one is selected.
Upvotes: 2