我在使用Android Studio构建的Android应用程序上实现了一个启动画面,我想在启动画面中添加一个微调器。任何人都可以帮我解决这个问题:
这是我的splashScreen.java类的代码:
package com.packagename.appname;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
/**
* Created by VAIO1 on 05/09/2014.
*/
public class splashScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
Thread logoTimer = new Thread() {
public void run() {
try {
sleep(3000);
Intent splashIntent = new Intent("com.packagename.appname.SPLASH");
startActivity(splashIntent);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
finish();
}
}
};
logoTimer.start();
}
@Override
protected void onPause() {
super.onPause();
}
}
这是我的splash.xml的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/splashId">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="@drawable/screen"
android:cropToPadding="false"
android:scaleType="fitXY"/>
</LinearLayout>
感谢您提供有关如何实现此目标的任何反馈。
答案 0 :(得分:1)
use this code :-
public class splashScreen extends Activity {
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.splash);
Thread logoTimer = new Thread() {
public void run() {
try {
sleep(3000);
progressDialog = new ProgressDialog(Sync_Screen_activity.this);
progressDialog.setMessage("Wait..");
progressDialog.setCancelable(false);
progressDialog.show();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent splashIntent = new Intent("com.packagename.appname.SPLASH");
startActivity(splashIntent);
finish();
}
}
};
logoTimer.start();
}
@Override
protected void onPause() {
super.onPause();
}
}