arimorty / floatingsearchview

A search view that implements a floating search bar also known as persistent search
https://github.com/arimorty/floatingsearchview/blob/master/README.md
Apache License 2.0
3.54k stars 667 forks source link

item.setIcon not work #302

Open Naguchennai opened 6 years ago

Naguchennai commented 6 years ago

item.setIcon not work any help?

 mSearchView.setOnMenuItemClickListener(new FloatingSearchView.OnMenuItemClickListener() {
        @Override
        public void onActionMenuItemSelected(MenuItem item) {

            if(gridorlist.equals("list")){
                SharedPreferences.Editor editor = getSharedPreferences("GRIDLIST", MODE_PRIVATE).edit();
                editor.putString("gridorlist", "grid");
                editor.apply();

                gridorlist ="grid";
                refreshview();

                if(item.getItemId() == R.id.action_grid) {
                    item.setIcon(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_grid));
                }

            }else{
                SharedPreferences.Editor editor = getSharedPreferences("GRIDLIST", MODE_PRIVATE).edit();
                editor.putString("gridorlist", "list");
                editor.apply();

                gridorlist ="list";
                refreshview();
                if(item.getItemId() == R.id.action_grid) {
                    item.setIcon(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_list));
                }
            }

        }
    });