How to setVisibility for control in TabActivity from Activity (tab)?

My TabActivity contains ProgressBar and two tabs (Activities with ListView).

Where does I must initialize progress = (ProgressBar)findViewById(R.id.progress_bc); and how can I set progress.setVisibility(View.GONE); from onItemClick in ListView in Activity?

<ProgressBar 
    android:id="@+id/progress_bc"
    android:indeterminate="true" 
    android:layout_width="18dip" 
    android:layout_height="18dip"
    style="@android:style/Widget.ProgressBar.Small"/>

Answers


The initialization should be to the Activity where you want to show the dialog. So it is better to have two ProgressBar, one for every layout of your two Activities and control it there.

So in the tab parent Activity (call it CustomTabActivity):

public ProgressDialog dialog;

In the onCreate() you initialize the dialog.

Now when you want to use it from a child Activity, you use:

((CustomTabActivity)getParent()).dialog.show(); or

((CustomTabActivity)getParent()).dialog.dismiss();

Hope this helps!


Need Your Help

Getting Error with memoized_finder method

ruby-on-rails ruby-on-rails-3 activerecord memoization

I trying to implement a memoized_finder method and I am getting an error that I don't understand.

get safari and chrome opened tabs on mac with Appcelerator

python safari applescript titanium appcelerator

I need to read opened tabs URL in Safari, Chrome and Firefox (optionally) and turn them into an array.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.