我正在一个页面上使用Spinner、EditText和Button。Spinner有以下选项...
接下来:
String[] Items = {
"Alarm",
"Office",
"Meeting",
"Party",
"Lunch",
"Breakfast",
"Supper",
"Home",
"Private",
"Outdoor",
"Family",
"Friends",
"others"
};
Spinner s1;
如果我在下拉菜单中选择“其他”选项,那么只有编辑框需要启用,否则它必须被禁用。如果我选择其他选项,则编辑框必须被禁用。
代码片段:
s1 = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, Items);
s1.setAdapter(adapter);
s1.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0,
View arg1, int arg2, long arg3)
{
int index = s1.getSelectedItemPosition();
Toast.makeText(getBaseContext(),
"You have selected item : " + Items[index],
Toast.LENGTH_SHORT).show();
}
public void onNothingSelected(AdapterView<?> arg0) {}
});
谢谢您,