【发布时间】:2010-12-26 11:17:14
【问题描述】:
我正在尝试使用开关盒。但它说我不能传递一个字符串:(
protected void onListItemClick(ListView l, View v, int position, long id) {
// super.onListItemClick(l, v, position, id);
String selection = l.getItemAtPosition(position).toString();
Log.i("Harsha", selection);
switch (selection) {
case "Compose":
break;
case "Inbox":
break;
case "Drafts":
break;
case "Sent":
break;
default:
break;
}
}
错误是
Cannot switch on a value of type String. Only convertible int values or enum constants are permitted
【问题讨论】:
标签: android listview switch-statement