【问题标题】:how to show progress bar moving from one activity to another activity in android如何在android中显示从一个活动移动到另一个活动的进度条
【发布时间】:2018-05-31 18:21:42
【问题描述】:

我想显示从一个活动到另一个活动的进度条,直到另一个活动被加载,任何人都可以举个例子

谢谢

【问题讨论】:

标签: android


【解决方案1】:

从当前活动切换到新活动时,您无法显示进度。

【讨论】:

    【解决方案2】:

    您可以通过在 xml 中的 ViewFlipper 中声明两个进度条来做到这一点。

        <?xml version="1.0" encoding="utf-8"?>
          <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/lah"
            >
           <ViewFlipper 
            android:id="@+id/myFlipper"
            android:layout_height="fill_parent"
            android:layout_width="fill_parent" 
            >
                <LinearLayout 
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
    
                <ProgressBar 
                          android:id="@+id/first_progressbar" />
                </LinearLayout> 
    
    
    
                <LinearLayout 
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
    
                <ProgressBar 
                          android:id="@+id/second_progressbar" />
    
                </LinearLayout> 
    
    
          </ViewFlipper>
    
      </LinearLayout>
    

    然后在你的 java 程序中创建一个 ViewFlipper 对象。

        ViewFlipper vf = (ViewFlipper) findViewById( R.id.myFlipper);
    

    然后调用

        vf.showNext();
    

    这样就可以显示两个ProgressBar。您还可以应用似乎 ProgressBars 从一个活动移动到下一个活动的动画。谢谢...

        vf.setInAnimation(AnimationUtils.loadAnimation( getApplicationContext(), R.anim.right_in ));
        vf.setOutAnimation( AnimationUtils.loadAnimation( getApplicationContext(), R.anim.left_out ));
        vf.showNext();
    

    【讨论】:

      猜你喜欢
      • 2013-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 2021-10-06
      相关资源
      最近更新 更多