简体   繁体   English

如何通过“活动”(标签)在TabActivity中设置控件的可见性?

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

My TabActivity contains ProgressBar and two tabs ( Activities with ListView ). 我的TabActivity包含ProgressBar和两个选项卡(带有ListView Activities )。

Where does I must initialize progress = (ProgressBar)findViewById(R.id.progress_bc); 我必须在哪里初始化progress = (ProgressBar)findViewById(R.id.progress_bc); and how can I set progress.setVisibility(View.GONE); 以及如何设置progress.setVisibility(View.GONE); from onItemClick in ListView in Activity ? onItemClickActivity ListView中?

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

The initialization should be to the Activity where you want to show the dialog. 初始化应该是要显示对话框的Activity So it is better to have two ProgressBar , one for every layout of your two Activities and control it there. 因此,最好有两个ProgressBar ,一个用于您两个Activities每种布局,并在那里进行控制。

So in the tab parent Activity (call it CustomTabActivity): 因此,在标签父活动(称为CustomTabActivity)中:

public ProgressDialog dialog;

In the onCreate() you initialize the dialog. onCreate() ,初始化对话框。

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! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM