我有一个由适配器填充的GridView
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
适配器的数据集基本上是一个混洗列表
static List<Integer> mTlist = Arrays.asList(
R.drawable.ac_pre, R.drawable.acc_pre,
R.drawable.acd_pre, R.drawable.ach_pre,
R.drawable.acs_pre, R.drawable.ad_pre,
R.drawable.ah_pre, R.drawable.as_pre,
R.drawable.dc_pre, R.drawable.dd_pre,
R.drawable.dh_pre, R.drawable.ds_pre,
R.drawable.fc_pre, R.drawable.fd_pre,
R.drawable.fh_pre, R.drawable.fs_pre,
R.drawable.jc_pre, R.drawable.jd_pre,
R.drawable.jh_pre, R.drawable.js_pre,
R.drawable.kc_pre, R.drawable.kd_pre,
R.drawable.kh_pre, R.drawable.ks_pre,
R.drawable.nc_pre, R.drawable.nd_pre,
R.drawable.nh_pre, R.drawable.ns_pre,
R.drawable.qc_pre, R.drawable.qd_pre,
R.drawable.qh_pre, R.drawable.qs_pre,
R.drawable.sec_pre, R.drawable.sed_pre,
R.drawable.seh_pre, R.drawable.ses_pre,
R.drawable.sic_pre, R.drawable.sid_pre,
R.drawable.sih_pre, R.drawable.sis_pre,
R.drawable.vc_pre, R.drawable.vd_pre,
R.drawable.vh_pre, R.drawable.vs_pre,
R.drawable.xc_pre, R.drawable.xd_pre,
R.drawable.xh_pre, R.drawable.xs_pre,
R.drawable.zc_pre, R.drawable.zd_pre,
R.drawable.zh_pre, R.drawable.zs_pre
);
private void mischen() {
Collections.shuffle(mTlist);
}
按下按钮后,从不同的活动我要删除项目
ImageAdapter imad = new ImageAdapter(getBaseContext());
Bundle extras = getIntent().getExtras();
Integer pos = extras.getInt("draw");
ImageAdapter.mTlist.remove(pos);
imad.notifyDataSetChanged();
finish();
pos是List (mTlist);
中项目的位置finish()
我回到GridView-Activity。
但问题是,一切都没有变化!我在去除后检查了位置上的项目,并且它与以前一样。
请帮忙! 问候你好
答案 0 :(得分:1)
您要求列表删除 Integer 类型的对象并且这是不正确的,因为您使用 ArrayList 。请尝试以下操作删除对象
ImageAdapter.mTlist.remove(pos.intValue());
问候。