我不确定它是否可能,但如果是的话,我将不胜感激您的帮助!我需要根据选中的单选按钮更改 textHint。例如,如果选中 US radioButton,我希望 editText 提示显示“Miles”;当检查RadioButton指标时,我希望Texthint显示“公里”。
我试图多次解决这个问题,但总是失败。
坦克提前!
我不确定它是否可能,但如果是的话,我将不胜感激您的帮助!我需要根据选中的单选按钮更改 textHint。例如,如果选中 US radioButton,我希望 editText 提示显示“Miles”;当检查RadioButton指标时,我希望Texthint显示“公里”。
我试图多次解决这个问题,但总是失败。
坦克提前!
您可以setHint(hint);
在 EditText 上使用来更改提示。您可以在单选按钮上使用侦听器来检测何时选择了一个。
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;
}
}
});