在android中使用ListView缓存列表

时间:2013-07-10 06:40:34

标签: android android-listview

您好我正在尝试开发一个应用程序,可以列出所有已安装的应用程序及其缓存,我正在这样做,但问题是,当我点击列表时,我得到Force Close

这是我的代码

new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() 
{
    pd = ProgressDialog.show(Messages.this, "Loading..","Please Wait", true, false);
}// End of onPreExecute method

@Override
protected Void doInBackground(Void... params) 
{
    MessageDetails Detail;
    Detail = new MessageDetails();
    Detail.setIcon(getPackageManager().getApplicationIcon( pStats.packageName ));
    Detail.setName(title);
    Detail.setSub("Cache Size -> "+(((pStats.cacheSize/1024) > 0)?(pStats.cacheSize/1024):"No Cache"));
    details.add(Detail);
    return null;
}// End of doInBackground method

@Override
protected void onPostExecute(Void result) {
    msgList.setAdapter(new CustomAdapter(details, Messages.this));
    pd.dismiss();
}// End of onPostExecute method
 }.execute((Void[]) null);

请提前帮助我解决这个问题。

堆栈跟踪

E/AndroidRuntime(1143): java.lang.IllegalStateException: The content of the adapter has 
changed but ListView did not receive a notification. 
Make sure the content of your adapter is not modified from a background thread, 
but only from the UI thread. 
[in ListView(2131230725, class android.widget.ListView) 
with Adapter(class com.example.temptocache.CustomAdapter)]

0 个答案:

没有答案