Skip to content

Instantly share code, notes, and snippets.

@kgundula
Created March 8, 2017 09:51
Show Gist options
  • Save kgundula/9e3408badff0a998d940a6454dde4b03 to your computer and use it in GitHub Desktop.
Save kgundula/9e3408badff0a998d940a6454dde4b03 to your computer and use it in GitHub Desktop.
Setting background color on the captureactivity
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