Hi,
I've a problem with ListViews. Everytime I try to add an item after it has first been shown, my program FC having following stack frame
Thread [<3> main] (Suspended (exception IllegalStateException))
ListView.layoutChildren() line: 1603
AbsListView$CheckForTap.run() line: 1827
ViewRoot(Handler).handleCallback(Message) line: 587
ViewRoot(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4363
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
The first time I add items everything works fine but when I add an item to the adapter after it has first been shown and touch the ListView on the Device it crashes.
I use the following Adapter
public class Adapterclass extends BaseAdapter{
//Adapter for Chatview...
private Context con;
private int count = 0;
private List<String>messages;
@Override
public int getCount() {
return count;
}
@Override
public Object getItem(int position) {
return messages.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView txt = new TextView(con);
txt.setText(Html.fromHtml(messages.get(position)));
return txt;
}
public void AddItem(String item){
messages.add(item);
count++;
}
Adapterclass(Context con){
this.con = con;
messages = new ArrayList<String>();
}
}
(To add an item I call AddItem) Do you have any suggestions? It drives me nuts since many hours =/