목록보기에 새 항목을 추가하고 목록보기에 여전히 표시된 이전 항목으로 새로 고칩니다. 이전에 나는SimpleAdapter를 사용하여 ListView를 새로 고칠 수 없습니다.
adapter.notifyDataSetChanged();
를 사용하여 새 항목을 추가 한 후 새로 고침 할 수 있었다 ArrayAdapter와를 사용했지만, 난 SimpleAdapter와 위의 코드를 사용할 수 없습니다입니다. 어떠한 제안? 몇 가지 솔루션을 시도했지만 지금까지 아무 것도 작동하지 않았습니다. 당신의 beta3
방법은 정말 ListView
에 새로운 항목을 추가하는 함수의 경우
void beta3 (String X, String Y){
//listview in the main activity
ListView POST = (ListView)findViewById(R.id.listView);
//list = new ArrayList<String>();
String data = bar.getText().toString();
String two= data.replace("X", "");
ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String, String>>();
HashMap<String,String> event = new HashMap<String, String>();
event.put(Config.TAG_one, X);
event.put(Config.TAG_two, two);
event.put(Config.TAG_three, Y);
list.add(event);
ListAdapter adapter = new SimpleAdapter(this, list, R.layout.list,
new String[]{Config.TAG_one, Config.TAG_two, Config.TAG_three},
new int[]{R.id.one, R.id.two, R.id.three});
POST.setAdapter(adapter);
}
는 [이] 중복 같아 (http://stackoverflow.com/questions/9733572/android-adding-extra-item-on-listview). 어떻게 항목을 목록에 추가하려고합니까? – gus27