Reputation: 692
I have an GridView filled by an Adapter
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));
The dataset of the Adapter is basicly a shuffled List
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);
}
from an diffrent Activity after pressing a button i want to remove an item
ImageAdapter imad = new ImageAdapter(getBaseContext());
Bundle extras = getIntent().getExtras();
Integer pos = extras.getInt("draw");
ImageAdapter.mTlist.remove(pos);
imad.notifyDataSetChanged();
finish();
pos is the position of the item in the List (mTlist);
with finish()
i go back to the GridView-Activity.
But the problem is, nothing changes at all! I checked with a toast the item on the position after the removing and it was the same as before.
Please help! Greetings ueen
Upvotes: 0
Views: 3185
Reputation: 2085
You're asking the list to delete an object of type Integer and that's not correct 'cause you use ArrayList. Try the following to delete your object
ImageAdapter.mTlist.remove(pos.intValue());
Regards.
Upvotes: 1