I have multiple buttons i want to change color of button . that i know , but how to save those colors in shared preference ?? and how to delete them from shared preferences ??
private void ShowPunch() {
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.fragment_edit_profile);
WS = (Button)dialog.findViewById(R.id.ws);
WE = (Button)dialog.findViewById(R.id.we);
LS = (Button)dialog.findViewById(R.id.lts);
LE = (Button)dialog.findViewById(R.id.lte);
PS = (Button)dialog.findViewById(R.id.pts);
PE = (Button)dialog.findViewById(R.id.pte);
MRMS = (Button)dialog.findViewById(R.id.mrms);
MRME = (Button)dialog.findViewById(R.id.mrme);
WS.setOnClickListener(this) ;
WE.setOnClickListener(this) ;
LS.setOnClickListener(this) ;
LE.setOnClickListener(this) ;
PS.setOnClickListener(this) ;
PE.setOnClickListener(this) ;
MRMS.setOnClickListener(this) ;
MRME.setOnClickListener(this) ;
dialog.show();
}
@SuppressLint("ResourceAsColor")
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ws:
Punching();
WS.setBackgroundColor(R.color.feedpos);
Toast.makeText(context, "Your Work Time Start From Now..", Toast.LENGTH_SHORT).show();
break;
case R.id.we:
Punchingwe();
Toast.makeText(context, "Your Work Time End Here..", Toast.LENGTH_SHORT).show();
WE.setBackgroundColor(myIntValue);
break;
case R.id.pts:
Punchingpts();
Toast.makeText(context, "Your Prayer Time Start From Now..", Toast.LENGTH_SHORT).show();
PS.setBackgroundColor(myIntValue);
break;
case R.id.pte:
Punchingpte();
Toast.makeText(context, "Your Prayer Time End Here..", Toast.LENGTH_SHORT).show();
PE.setBackgroundColor(myIntValue);
break;
case R.id.lts:
Punchinglts();
Toast.makeText(context, "Your Lunch Time Start From Now..", Toast.LENGTH_SHORT).show();
LS.setBackgroundColor(myIntValue);
break;
case R.id.lte:
Punchinglte();
Toast.makeText(context, "Your Lunch Time End Here..", Toast.LENGTH_SHORT).show();
LE.setBackgroundColor(myIntValue);
break;
case R.id.mrms:
Punchingmrms();
Toast.makeText(context, "Your MRM Time Start From Now..", Toast.LENGTH_SHORT).show();
MRMS.setBackgroundColor(myIntValue);
break;
case R.id.mrme:
Punchingmrme();
Toast.makeText(context, "Your MRM Time End Here..", Toast.LENGTH_SHORT).show();
MRME.setBackgroundColor(myIntValue);
break;
default:
break;
}
}