1

How can I reference the Activity View from within the onCreate() method so I can use view.setKeepScreenOn().

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
bugzy
  • 7,086
  • 9
  • 42
  • 44

2 Answers2

3

You can get a specific view defined in your xml file like:

   View view = findViewById(R.id.my_view);
Cheryl Simon
  • 46,552
  • 15
  • 93
  • 82
1

You could also use android:keepScreenOn in your layout xml to have it set automatically when your layout is inflated. See the docs.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Al.
  • 76
  • 1