adapter.notifyDataSetChanged(); 안드로이드에서 작동하지 않습니다 for 루프에서 값을 검색하지만 값이 화면에 표시되지 않습니다. 내 자바 파일 :NotifyDataSetChanged가 내 코드에서 작동하지 않습니다.
이private static final String TAG_NAME="Notification";
String[] resultsAsString = {""};
ListView listView;
ArrayAdapter<String> adapter;
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, resultsAsString);
ParseQuery<ParseObject> parseObjectParseQuery=new ParseQuery<ParseObject>("PushNotifications");
parseObjectParseQuery.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
if (e==null){
resultsAsString = new String[objects.size()];
Log.d(TAG_NAME,"Objects size in MyService is:"+objects.size());
if(objects.size()>0){
Log.d(TAG_NAME,"Object size is "+objects.size());
for(int index = 0; index < objects.size(); index++){
resultsAsString[index] = objects.get(index).getString("Message");
Log.d(TAG_NAME,"result value is:"+resultsAsString[index]);
}
adapter.notifyDataSetChanged();
}else {
Log.d(TAG_NAME,"Object size is "+objects.size());
}
}
}
});
listView = (ListView) findViewById(R.id.notificatio_listView);
listView.setAdapter(adapter);
내 로그 캣 표시 : 객체이면 MyService의 크기 : 3 개체 크기는 새로운 배열을 생성하고
objects.size()가> 0인지 확인 하시겠습니까? – Opiatefuchs
그래, 개체 크기가 3이고 나는 루프 –
및 ... 일반적으로, adapterView를 어댑터를 설정 한 후 adapterNotifyDataSetChanged()를 호출 할 수 있습니다 ...... – Opiatefuchs