Update gridview after selecting an item from it

1

Hello friends, I would like you to help me update a gridview after selecting one of its items, ie within the onItemClickListener event or if there is another form but that is updated after selecting an item from the grid.

I show you some of the code

  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.juegodeletra);


    adaptadorimagenjuego adap = new adaptadorimagenjuego(this, nu());
    barra = (ProgressBar) findViewById(R.id.progressBar);
    gridView = (GridView) findViewById(R.id.grid1);
    gridView.setAdapter(adap);

    muss();
    alertas();



    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if(dato==position){


            }
            else{

            }

        }
    });

I want that in the onItemClick method if the condition is fulfilled, update my gridview, I would appreciate any contribution from friends

    
asked by flapon22 19.08.2016 в 06:32
source

1 answer

1

Simply call the invalidateViews () method to update your GridView.

gridview.InvalidateViews();

If you use an Adapter, you can also update it by running notifyDatasetChanged () :

gridview.setAdapter(adapter);
adapter.notifyDataChanged();
    
answered by 19.08.2016 / 11:49
source