@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Get the resources for the context of the presentation. // Notice that we are getting the resources from the context of the presentation. Resources r = getContext().getResources(); // Inflate the layout. setContentView(R.layout.presentation_content); final Display display = getDisplay(); final int displayId = display.getDisplayId(); final int photo = mContents.photo; // Show a caption to describe what's going on. TextView text = (TextView)findViewById(R.id.text); text.setText(r.getString(R.string.presentation_photo_text, photo, displayId, display.getName())); // Show a n image for visual interest. ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(r.getDrawable(PHOTOS[photo])); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); // Set the background to a random gradient. Point p = new Point(); getDisplay().getSize(p); drawable.setGradientRadius(Math.max(p.x, p.y) / 2); drawable.setColors(mContents.colors); findViewById(android.R.id.content).setBackground(drawable); } }
@Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Get the resources for the context of the presentation. // Notice that we are getting the resources from the context of the presentation. Resources r = getContext().getResources(); // Inflate the layout. setContentView(R.layout.presentation_content); final Display display = getDisplay(); final int displayId = display.getDisplayId(); final int photo = mContents.photo; // Show a caption to describe what's going on. TextView text = (TextView)findViewById(R.id.text); text.setText(r.getString(R.string.presentation_photo_text, photo, displayId, display.getName())); // Show a n image for visual interest. ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(r.getDrawable(PHOTOS[photo])); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); // Set the background to a random gradient. Point p = new Point(); getDisplay().getSize(p); drawable.setGradientRadius(Math.max(p.x, p.y) / 2); drawable.setColors(mContents.colors); findViewById(android.R.id.content).setBackground(drawable); } }