findViewById(int id) is a method of the View and Activity classes. This method will take a resource Id usually in the form of R.id.mView and will return to you a View object that is a reference to that View. Note that the returned object will nearly always need to be cast to the correct type of View before you can start interacting with it. If a View by the given ID does not exist within the current activity or parent View then you will receive null.
Questions tagged [findviewbyid]
563 questions
-2
votes
2 answers
surfaceview + buttons findviewbyid returns null
My code is ok but unfortunately my code gives me null pointer exception. I know that by writing the setcontentview before findviewbyid it wont happen but then by doing so my surface does not update.I tried lot searching about this but i am not able…

hitman_93
- 116
- 9
-3
votes
2 answers
How can I use findViewById within a static method?
I would like to use findViewById in my method setTotalSum which is called from another class.
How can I use it although it's a static method?
public SecondaryDisplay(Context outerContext, Display display) {
super(outerContext,…

annanas
- 1
-3
votes
3 answers
-3
votes
4 answers
Activity.findViewById() error "expected resource of type id" on R.layout object
I'm following this online tutorial to build a part of my app that will return a list of my contacts, but I've run in to a bit of an issue that doesn't seem to be mentioned anywhere in the tutorial.
This is in the class ContactsFragment, which is not…

marcuthh
- 592
- 3
- 16
- 42
-3
votes
2 answers
findViewById from different layout/xml file Android Studio
I'm trying to create a settings page for my app which has the radioGroup for 3 options to help users change the colour of the text in differrent layout/xml file. But in mysettings page I cant call the view from different layout, any idea?
Below are…

Harper Mina
- 15
- 6
-4
votes
2 answers
What is timerSeekBar in this java code an object or variable?What is findViewById,
I checked findViewById is a method so what is timerSeekBar, an object or a variable,got told its a variable but we are calling methods with it so it should'nt it be an object.Please explain why are we writing SeekBar before findViewById.
SeekBar…

rov_0
- 7
- 6
-4
votes
1 answer
ListView is null, why?
In a fragment I am trying to set up a list view. In onCreateView() :
mFindFriendsOptionsListView = (ListView) view.findViewById(R.id.find_friends_list_view);
mFindFriendsOptionsAdapter = new FindFriendsOptionsAdapter(mFindFriendOptionIconIds,…

Tom Finet
- 2,056
- 6
- 30
- 54
-5
votes
3 answers
ImageView may return Null?
I have a fragment that is half image and then half text.
Trying to assign the ImageView and the TextView but it says:
Might give null
and when I run the app it does not run.
I included the Java and XML files for fragment and included the…

asdddd
- 51
- 1
- 4