我正在尝试使用 if else 方法初始化一个字符串数组。但它不起作用。怎么做 ?
if(itemno==2){
String[] values = new String[] { "Category31",
"Category32",
"Category33",
"Category34",
"Category35",
"Category36",
"Category37",
"Android Example List View" ,
"daniel",
"dude",
"hello",
"super,","dukker"
};}
else if(itemno==3){
String[] values = new String[] { "Category31",
"Category32",
"Category33",
"Category34",
"Category35",
"Category36",
"Category37",
"Android Example List View" ,
"daniel",
"dude",
"hello",
"super,","dukker"
};}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
l.setAdapter(adapter);
但在适配器中显示变量不被接受的错误..帮助我