我正在使用自定义标题视图,并希望在线程工作时在标题视图中显示/隐藏进度条.
这是我的标题视图的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/image_left_btn"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:text="Back"
/>
<TextView
android:id="@+id/image_title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20dip"
android:textStyle="bold"
android:textColor="#fff"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="8dip"
android:paddingRight="8dip"
/>
<ProgressBar
android:id="@+android:id/progress_small_title"
style="?android:attr/progressBarStyleSmall"
android:layout_width="75dip"
android:layout_height="wrap_content"
android:paddingRight="8dip"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在我的Activity中,将此设置为自定义标题栏后,我执行此操作
titleProgress = (ProgressBar)findViewById(R.id.progress_small_title);
titleProgress.setVisibility(View.INVISIBLE);
Run Code Online (Sandbox Code Playgroud)
其中titleProgress是ProgressBar对象.
这就是我在我的线程中所做的
runOnUiThread(new Runnable() {
public void run() {
titleProgress.setVisibility(View.VISIBLE);
}
});
//long operation here
runOnUiThread(new Runnable() {
public void run() {
titleProgress.setVisibility(View.INVISIBLE);
}
});
Run Code Online (Sandbox Code Playgroud)
但进度条没有变化.永远不会显示.有人可以告诉我代码有什么问题吗?
是否可以在自定义标题中显示标题进度条?
谢谢.
android ×1