I'm still facing with a favorite button which should save my layout and set the layout as the layout of a new activity .. The problem is that my activity which should open the layout I saved, doesn't do that, but I don't understand why.. Here is my code:
public void AddToFavoriteListener(final View v){
SharedPreferences prefs=getSharedPreferences("MYPREF",MODE_PRIVATE);
int favActivity=prefs.getInt("FAV_ACTIVITY", 0);
switch(favActivity){
case 0:
Toast.makeText(getApplication(),"Favorite not set.",Toast.LENGTH_SHORT).show();
break;
case 1:
//code to open first activity
break;
case 2:
//code to open second activity
break;
}
return;
And here is the code for saving the layout:
public void AddToFavorite(View v){
SharedPreferences pref=getSharedPreferences("MYPREF",MODE_PRIVATE);
SharedPreferences.Editor editor=pref.edit();
int activityNum = 0;
editor.putInt("FAV_ACTIVITY", activityNum);
editor.commit();
}
Thanks a lot !
L.E: I edited the first code for the activity which should be open the saved layout, but the button still opens a black activity..