I have a layout like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@drawable/menu_background"
>
<ProgressBar
android:id="@+id/aPBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@android:style/Widget.ProgressBar.Inverse"/>
...
</RelativeLayout>
And in my onCreate method I do this to hide the ProgressBar at first:
LayoutInflater inflater = getLayoutInflater();
RelativeLayout layout = (RelativeLayout)inflater.inflate(R.layout.achievements_screen, null);
progressBar=(ProgressBar)layout.findViewById(R.id.aPBar);
progressBar.setVisibility(View.INVISIBLE);
But the ProgressBar
is still visible all the time ... I also tried View.GONE
.
When i set
android:visible="gone"
in the XML file, the ProgressBar
doesnt show up, but I can't make it appear with
progressBar.setVisibility(View.Visible);
What is difference between ProgressBar and SeekBar? An example of SeekBar is your device's brightness control and volume control. Important Note: Attribute of a SeekBar are same as ProgressBar and the only difference is user determine the progress by moving a slider (thumb) in SeekBar.
ProgressBar is used to display the progress of an activity while the user is waiting. You can display an indeterminate progress (spinning wheel) or result-based progress.
In Android, by default a progress bar will be displayed as a spinning wheel but If we want it to be displayed as a horizontal bar then we need to use style attribute as horizontal. It mainly use the “android. widget. ProgressBar” class.
ProgressBars are used as loading indicators in android applications. These are generally used when the application is loading the data from the server or database. There are different types of progress bars used within the android application as loading indicators.
You are inflating a new view using the Layout Inflater. This is NOT the view currently on the screen.
Therefore changing it's visibility won't affect the screen UI.
Further up your Activity you must have called setContentView
and this is the layout that is visible on your UI.
Therefore calling:
findViewById
will return your progress bar on the screen, but calling layout.findViewById
will return that layouts progress bar (correctly) but that is not the progressBar you can see on your screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With