Created
March 8, 2017 09:51
-
-
Save kgundula/9e3408badff0a998d940a6454dde4b03 to your computer and use it in GitHub Desktop.
Setting background color on the captureactivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package za.co.gundula.app.androidcolorpicker; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
import android.os.Bundle; | |
import android.preference.PreferenceManager; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
import android.widget.TextView; | |
public class CaptureActivity extends AppCompatActivity { | |
Context context; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_capture); | |
context = getApplicationContext(); | |
TextView text = (TextView) findViewById(R.id.text); | |
View root = text.getRootView(); | |
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); | |
int backgroundColor = sp.getInt("capture_background_color", -1); | |
if (backgroundColor != -1) { | |
root.setBackgroundColor(backgroundColor); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment