【问题标题】:How to Put set delay on android Progress bar如何在android进度条上设置延迟
【发布时间】:2012-04-26 23:01:03
【问题描述】:

我想要设置它,让进度条加载 15 秒,然后继续下一个活动。

现在活动有:

public class MainActivity extends Activity {

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button btn5 =(Button)findViewById(R.id.button);

    btn5.setOnClickListener(new Button.OnClickListener() {

      public void onClick(View v) {
        Intent myIntent = new Intent();

        myIntent.setAction(Intent.ACTION_VIEW);

        myIntent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
        setContentView(R.layout.loading);

      }        
    });
  }

}

而xml页面有:

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="match_parent"
    android:layout_height="144dp"
    android:layout_gravity="center_vertical" />

我想知道如何让progressBar1加载15秒然后转到result.xml

【问题讨论】:

  • 查看 StackOverflow 上的所有“启动画面”问答,因为这在行为方面是相同的。最快的选择可能是在Handler 上发布Runnable,延迟15 秒,然后开始您的第三个Activity
  • 您可以创建一个单独的线程来处理进度条,在线程中提供所需的延迟,然后关闭进度条...

标签: android xml loading android-progressbar


【解决方案1】:

查看 sdk 示例代码中包含的 api 演示中的进度对话框示例。我相信它在 /src/com/example/android/apis/app/AlertDialogSamples.java 中。如果您查看最底部,它有代码通过时间延迟消息更新进度条。

您的问题有点不清楚,您发布的第一个或第二个活动的代码是什么

【讨论】:

  • 我点击一个按钮来启动这个活动,它等待然后打开第三个活动,目标。
猜你喜欢
  • 1970-01-01
  • 2013-03-30
  • 1970-01-01
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多