I have Already changed menu item dynamically but when app get restarted it changes back to default icon.How can i changed that icon permanently?
case R.id.action_bookmark:
String isBookmark=data.getBookmark();
if(isBookmark.equals("false")) {
NewsModel newsModel=items.get(getAdapterPosition());
newsModel.setBookmark("true");
ContentValues values = newsModel.getContentValues();
NewsTable.getInstance().updateEntry(newsModel.getId(),values);
item.setIcon(R.drawable.star);
notifyDataSetChanged();
}
else{
NewsModel newsModel=items.get(getAdapterPosition());
newsModel.setBookmark("false");
ContentValues values = newsModel.getContentValues();
NewsTable.getInstance().updateEntry(newsModel.getId(),values);
item.setIcon(R.drawable.ic_bookmark_white_24dp);
notifyDataSetChanged();
}
Aucun commentaire:
Enregistrer un commentaire