public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listascombarra);
listView = (ListView)findViewById(android.R.id.list);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
COUNTRIES[it]="TESTES";
it++;
}
});
}
protected void onStart() {
super.onStart();
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, COUNTRIES);
listView.setAdapter(adapter);
}
So I have problems with the event, because when I click on an ItemList the string COUNTRIES don’t modify, but if I scroll down it is modified sometimes. Is weird, some help?
Look at the pastebin url:
You are changing the string array that is part of the adapter, but you need to notify the list view (which is built using the adapter) that the string array has changed.
You can do this via the:
function of the ArrayAdapter class. So in your on click function, call notifyDataSetChanged and see if that helps.