Я не могу изменить фон SnackBar. Это как обычная кнопка, я хочу только цветной Undo
текст с функциональностью кнопки. Как я могу это реализовать?
SwipeToDelteCallBack. java
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
int position = viewHolder.getAdapterPosition();
adapter.dismissjob(viewHolder.getAdapterPosition());
final Snackbar snackbar = Snackbar.make(viewHolder.itemView.getRootView(),"Deleted", LENGTH_LONG).setAction(R.string.SnackUndo, new Remove_job_recycle_adapter.UndoListener(position));
View snackbarview = snackbar.getView();
snackbar.setActionTextColor(Color.GREEN);
TextView snackbartextview = snackbarview.findViewById(R.id.snackbar_text);
snackbar.show();
Remove_job_Recycle_adapter. java
public static class UndoListener implements View.OnClickListener {
int pos;
public UndoListener(int pos){
this.pos = pos;
}
@SuppressLint({"ResourceAsColor", "Range"})
@Override
public void onClick(View v) {
remove_job_recycleList.add(pos, data);
SwipeToDeleteCallback.adapter.notifyDataSetChanged();
Snackbar snackbar1 = Snackbar.make(v,"Restored",Snackbar.LENGTH_SHORT);
View snackbar1View = snackbar1.getView();
TextView textView = snackbar1View.findViewById(R.id.snackbar_action);
textView.setTextColor(Color.GREEN);
snackbar1View.setBackgroundColor(R.color.green);
snackbar1.show();