I am trying to make simple list view as follows. I am keep getting syntax error. Could you help me on this? Thanks in advance. What is the cause?
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);
}
}
It is caused by the next line Items = new ArrayList<String>();
. Add a variable name there and the syntax error goes away. The compiler simply fails to realize just what the error was.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments