用于窗口小部件更新的RemoteViews超出了最大位图内存使用量

时间:2015-01-27 05:38:24

标签: java android bitmap widget

我有一个列表视图的自定义适配器。

 public class Manage extends BaseAdapter {

    public Manage(Context context, List<source> list) {
        mList = list;
        this.context=context;       
        mInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public void addItems(List<source> newItems) {
        if (null == newItems || newItems.size() <= 0) {
            return;
        }

        if (null == mList) {
            mList = new ArrayList<source>();
        }

        mList.addAll(newItems);
        notifyDataSetChanged();
    }

    public void clearItems() {
        mList.clear();
        notifyDataSetChanged();
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        TextView textView = null;
        if (null == convertView) {
            convertView = mInflater.inflate(R.layout.list_item, null);

            textView = (TextView) convertView.findViewById(R.id.textView);

            convertView.setTag(textView);
        } else {
            textView = (TextView) convertView.getTag();
        }
        final String text = (String) mList.get(position).getTitle();
        textView.setText(text);
        textView.setTypeface(face);

        return convertView;
    }
}

并在我的班级更新列表视图中使用以下代码:

adaptertext.addItems(data);

我的列表视图非常小(最多15个项目),但为我显示此错误:

java.lang.IllegalArgumentException: RemoteViews for widget update exceeds maximum bitmap memory usage (used: 5814036, max: 5529600) The total memory cannot exceed that required to fill the device\\\'s screen once.
    at android.os.Parcel.readException(Parcel.java:1435)
    at android.os.Parcel.readException(Parcel.java:1385)
    at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetIds(IAppWidgetService.java:638)
    at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:406)
    at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:473)
    at com.app.myapp.pc.b(Unknown Source)
    at com.app.myapp.bn.run(Unknown Source)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:5493)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
    at dalvik.system.NativeStart.main(Native Method)

如何解决它请在我的代码中显示? TNX

0 个答案:

没有答案