yon*_*yon 6 android progress-bar
我有这样的布局:
<?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>
Run Code Online (Sandbox Code Playgroud)
在我的onCreate方法中,我这样做是为了首先隐藏ProgressBar:
LayoutInflater inflater = getLayoutInflater();
RelativeLayout layout = (RelativeLayout)inflater.inflate(R.layout.achievements_screen, null);
progressBar=(ProgressBar)layout.findViewById(R.id.aPBar);
progressBar.setVisibility(View.INVISIBLE);
Run Code Online (Sandbox Code Playgroud)
但是这一直ProgressBar是可见的......我也试过了View.GONE.
当我设置
android:visible="gone"
Run Code Online (Sandbox Code Playgroud)
在XML文件中,ProgressBar不显示,但我无法使其显示
progressBar.setVisibility(View.Visible);
Run Code Online (Sandbox Code Playgroud)
您正在使用布局膨胀器膨胀一个新视图。这不是当前屏幕上的视图。
因此,更改其可见性不会影响屏幕 UI。
您必须进一步调用您的 Activity setContentView,这是您的 UI 上可见的布局。
因此调用:
findViewById将在屏幕上返回进度条,但调用layout.findViewById将返回该布局进度条(正确),但这不是您可以在屏幕上看到的进度条。
| 归档时间: |
|
| 查看次数: |
4636 次 |
| 最近记录: |