Android Realm - RealmBaseAdapter内存问题

时间:2015-06-09 18:40:09

标签: android realm

我的RealmBaseAdapter存在内存问题。问题是当创建ListView的新行并且系统需要释放内存时内存会增加,这似乎会破坏我的" comercios"当我滚动列表时,RealmResults和应用程序崩溃。我不太确定发生了什么。提前谢谢。

我的代码:

public class ComercioAdapter extends RealmBaseAdapter<Comercio> implements ListAdapter {

    public ComercioAdapter(Context context, RealmResults<Comercio> comercios) {
        super(context, comercios, false);
    }

    public void reloadData(RealmResults<Comercio> comercios){
        this.realmResults = comercios;
        notifyDataSetChanged();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;

        if (view == null) {
            view = ((Activity) context).getLayoutInflater().inflate(R.layout.adapter_comercio, null);
            holder = new ViewHolder();
            holder.name = (TextView) view.findViewById(R.id.name);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        Comercio comercio = getItem(i);
        holder.name.setText(comercio.getName());
        return view;
    }

    private class ViewHolder {
        private TextView name;
    }
}

错误日志: 06-09 20:12:01.511 4406-4406/com.cmrlife.development A/libc﹕ Fatal signal 11 (SIGSEGV) at 0x00f600f2 (code=1), thread 4406

0 个答案:

没有答案