What is timerSeekBar in this java code an object or variable?What is findViewById,
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 -Class,findViewById- Method ?,timerSeekBar- variable or object? SeekBar timerSeekBar = (SeekBar)findViewById(R.id.timerSeekBar); timerSeekBar.setMax(600); timerSeekBar.setProgress(30);
TextView answerLabel = (TextView) findViewById(R.id.button1);
findViewByIdreturns an instance of the class that is actually used to define that view in your XML file. (Seekbar) is used to cast that view with specific view.
You have to cast that(
findViewById) to the class that your variable is defined when you use it. So, This is the reason for
SeekBar timerSeekBar = (SeekBar)findViewById(R.id.timerSeekBar);
From API 26, findViewById uses inference for its return type, so you no longer have to cast.
Please check below reference link : https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/SeekBar.java
ProgressBar is super class, AbsSeekbar is Child class of Progressbar and SeekBar is childclass of AbsSeekbar.
setMax() is method of Seekbar and setProgress() is method of Progressbar.
SeekBar is a widget.. It is defined in a file SeekBar.java ..essentially it is a
Viewin android. Seekbar extends the base class
findViewById()method is used to find a
viewin android with a particular id set for the
setId()method. We use
SeekBar timerSeekBar = (SeekBar)findViewById(R.id.timerSeekBar);so as to tell the system that we are looking for a view using
findViewById()method and then casting the base
View.classtype object to a subclass
(SeekBar)is used to tell the system that this
viewis an instance of