Hi I am total beginner in java and android stuff but I wanted to make an activity that works like settings: changing the background color and font color as well.
package com.example.bartek.smb;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class OptionActivity extends AppCompatActivity {
private Button but1;
private Button but2;
private View view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_option);
view = this.getWindow().getDecorView();
but1 = findViewById(R.id.rednut);
but2 = findViewById(R.id.greenbut);
}
public void goRed(View v){
but1.setTextColor(Color.RED);
view.setBackgroundResource(R.color.red);
}
public void goGreen(View v){
but2.setTextColor(Color.GREEN);
view.setBackgroundResource(R.color.green);
}
}
So I made 2 buttons that change font color and background but it only applies to current activity and disappears after shutting the device down. I have read about shared preferences but I don't know how to implement it.