Android : Simple List View in Andriod crashes if ArrayList is not empty

on Friday, September 12, 2014


Hello i have a Problem with a ListView


Here my Code



private void setViewProtocol() {
setContentView(R.layout.protocol);
List<String> logs = new ArrayList<String>();
logs.add("TEST 1");

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.protocol, logs);
ListView lv = (ListView) findViewById(R.id.listView1);
lv.setAdapter(adapter);
}


It crashes - but when I remove the line logs.add("TEST 1"); it works


Can anyone help me - why does it work when I call it with an emty list


Thanks


0 comments:

Post a Comment