我正在尝试制作简单的列表视图,如下所示。我一直在收到语法错误。你能帮帮我吗?提前致谢。原因是什么?
public class BlockListViewActivity extends Activity {
Button previousButton;
Button addButton;
Button deleteButton;
ArrayList<String> Items;
ArrayAdapter<String> Adapter;
ListView listview1; // Syntax error ";", ,expected
Items = new ArrayList<String>();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.blocklist);
Items = new ArrayList<String>();
Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, Items);
previousButton = (Button)findViewById(R.id.previousButton);
addButton = (Button)findViewById(R.id.addButton);
deleteButton = (Button)findViewById(R.id.deleteButton);
listview1 = (ListView)findViewById(R.id.blockListView);
listview1.setAdapter(Adapter);
listview1.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
}
答案 0 :(得分:0)
这是由下一行Items = new ArrayList<String>();
引起的。在那里添加变量名称,语法错误就消失了。编译器根本没有意识到错误是什么。