I need to create a switchbutton in one activity that will change the background and words colors in all other activities.
I tried create an activity to work like a master page, whatever is change there will change in all activitys, bur didn’t work properly.
Any ideas to make a switchbutton do that will be helpful.
This was my try on the master page:
public class MainActivity extends Activity { boolean iscolor = true;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.btn);
final LinearLayout layout = (LinearLayout)
findViewById(R.id.LinearLayout1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if(iscolor)
{
layout.setBackgroundColor(Color.BLUE);
iscolor = false;
}
else
{
layout.setBackgroundColor(Color.WHITE);
iscolor = true;
}
}
});
}