1
ListActivty에 대한 사용자 정의 기본 어댑터가 있습니다.어댑터 notifyDataSetChanged는 postDelayed 일 때만 작동합니다.
@Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
String pkg = mAdapter.getItem(position).toString();
boolean isProtected = ApplicationUtils.isPackageProtected(this, pkg) != null;
PreferenceUtils.setPreference(mContext, null, pkg, !isProtected, false);
mAdapter.notifyDataSetChanged();
}
그러나, notifyDataSetChanged 목록보기를 업데이트하지 않습니다 내가 어떤 항목을 클릭 한 후 목록을 업데이트하기 위해 노력하고있어,이 내 onListItemClick 코드입니다. 해결 방법으로 foor
@Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
String pkg = mAdapter.getItem(position).toString();
boolean isProtected = ApplicationUtils.isPackageProtected(this, pkg) != null;
PreferenceUtils.setPreference(mContext, null, pkg, !isProtected, false);
Handler adapterHandler = new Handler();
adapterHandler.postDelayed(new Runnable() {
@Override
public void run() {
mAdapter.notifyDataSetChanged();
}
}, 500);
}
누군가가 내게 왜 이런 일이 발생하는지 알려주고 다른 해결책이 있는지 말해 줄 수 있습니까?
감사합니다.