Questions tagged [findviewbyid]

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.

563 questions
-2
votes
2 answers

returns an object or a refrence to object

Does findViewById() and inflate() return a view object or "view reference" ?, asking because we do LinearLayout linear=(LinearLayout)inflate(R.layout.main,null); So if inflate return view Object ,and view is parent of LinearLayout the how can…
Asim Khan
  • 51
  • 6
-2
votes
1 answer

How to pass a variable to findViewById method using classes and instances?

I've been trying to make this tic-tac-toe game on android studios recently, I only have basic knowledge about android studio and java so i wanted to accomplish this app by making classes and objects, but whenever i try to run my app the app crashes…
rohit901
  • 110
  • 11
-2
votes
1 answer

findViewById returns null on Nougat, but not Marshmallow

In Marshmallow, everything works as it should. However, in Nougat, I get a void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference error. The currentWorkoutDisplay remains null, even after TextView…
Ross Wardrup
  • 311
  • 1
  • 9
  • 26
-2
votes
2 answers

How make findViewByID global

Good evening, I have a problem, I want to declare "finViewById" one time as global. But it only works as local one and so I have to copy and paste them, which is bad. public class MainActivity extends AppCompatActivity { //(I WANT…
user7026004
-2
votes
1 answer

Why RecyclerView is null?

I try to create a list of cards with info on it. So, I have main activity, which starts card activity: public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if…
-2
votes
2 answers

what is the implementation of function findViewById in android

I just start to learn Android. I know Android is the open source OS. I use android studio for develop the software. I known the function findViewById. I want to know the implementation of this function. I just see below. Could you please help to…
Android Dev
  • 11
  • 1
  • 1
-2
votes
3 answers

error: cannot find symbol method findviewbyid

I have got an app with a tabLayout of 2 fragments with listView and I want to load the content from a URLConnection with Json but in the Fragment.java file I geht the Error: can't resolve method 'findViewByID(int)'. public class Fragment1…
nolags
  • 633
  • 1
  • 11
  • 30
-2
votes
1 answer

cannot resolve 'findviewbyid(int)'

excuse me for repeating this question, but i saw the other answers and i just can't get it right. I'm new to android, and new to english :/ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import…
dreameral
  • 121
  • 1
  • 9
-2
votes
1 answer

NullPointerExcpetion on findViewById

I'm trying to build a basic table view with a few rows and columns populated with textviews to represent a lesson timetable. I have written some code which works out what lesson I would have using date and time, then change the colour of its…
-2
votes
3 answers

Null pointer when I try to findViewById and call setAlpha

My Activity: import android.support.v7.widget.Toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
quantumpotato
  • 9,637
  • 14
  • 70
  • 146
-2
votes
2 answers

FindViewByID - Null Pointer Exception! [ANDROID STUDIO]

I am very new with Android Studio, so there are many things I Need help for. One of these is that annoying findViewById(). Here is the most important part of my MainActivity.java public class MainActivity extends ActionBarActivity { public Button…
Niemand
  • 21
  • 4
  • 8
-2
votes
1 answer

findViewbyId returns null - but not when put into a button onClick listener

I want to access a TextView to exhange its label. However, findViewById seems to return null when the code is in onCreate(), onResume() or onStart(). The application crashes only if the //if(Day != null) is not commented by //. The code snippet…
Vince
  • 3
  • 3
-2
votes
3 answers

I Can't use my findViewById from AsyncClass

I Can't use findViewById() from my Kclass=( How can i use it? ` private class BackGroundTask extends AsyncTask{ @Override protected Void doInBackground(Void... params) { try { //execute -…
Raqim
  • 93
  • 1
  • 1
  • 6
-2
votes
1 answer

android - findViewById using a String

I have many many ImageButtons, and i want to use something to shortcut the code. Like use findViewById method with a String value same findViewById("R.id.btn_name"), or get button by tag, or something like this. Thanks in Advance.
-2
votes
2 answers

getActivity.findViewById() or mView.findViewById()

I would like to know why sometime getActivity.findViewById() works and sometimes it returns null ? And with myView.findViewById() it works ? Thanks in advance :)
nsvir
  • 8,781
  • 10
  • 32
  • 47
1 2 3
37
38