Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to empty a gridview on Android?

I am developping a launcher with two different profiles : one is the main one the other is secondary. If I go on the play store and then come back with the "back" button, I land on my main profile, but there, the icons of my gridview (displayed through an adapter) appear in double (if I install two apps from the play store, coming back with the back button will give me icons 3 times and so on).

If I restart my main activity in the onresume method, things go fine and my icons aren't doubled, or tripled or whaterver. But I don't want to restart the activity, I only want to empty my gridview.

if((admin == true) ){
        Intent intent = getIntent();
        finish();
        startActivity(intent);}
like image 681
Zizou Avatar asked Dec 05 '25 00:12

Zizou


1 Answers

I had the same problem myself. The easiest way to do this is:

gridview.setAdapter(null);
like image 119
Bogdan Alexandru Avatar answered Dec 06 '25 16:12

Bogdan Alexandru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!