Hello.
Help, I'm new to Java :)
It is necessary to break down by concepts: TextView myTextView = (TextView)findViewById(R.id.tvCat) ;
TextView -myTextView -(TextView) -R.id.tvCat -
Mostly clear, but confused, because have the same values.
Hello.
Help, I'm new to Java :)
It is necessary to break down by concepts: TextView myTextView = (TextView)findViewById(R.id.tvCat) ;
TextView -myTextView -(TextView) -R.id.tvCat -
Mostly clear, but confused, because have the same values.
Maybe it will be clearer, I don’t know, TextView myTextView is that you created a link, then, using the equal sign, you specify a link to the object to which it will refer. A simple example can be shown as follows. String string = new String(); Now you can access the previously created new String() object via the string reference. Those. calling methods referring to the link string.replace() , etc.
In your situation, you do not create a new object, but so to speak, request it by calling a method that returns (return) an object of type View, you pass in the argument of the findViewById(ТУТ) method to the ID of the requested findViewById(R.id.tvCat) . But since you need an object of type TextView, you cast ( article: casting ) the View object in TextView, if you can do this, otherwise there will be an error.
ps I myself a novice, for inaccuracies, please do not kick))
myTextView , etc. and what is the TextView class? what does he do? - ikeryaTextView class belongs to a group of Android widgets , that is, classes that display information on the device screen — everything you see on the screen is implemented with their help — buttons, switches, pictures, text, sliders, and everything else. That class TextView is responsible for displaying text on the screen. - pavlofffSource: https://ru.stackoverflow.com/questions/537234/
All Articles