【发布时间】:2015-08-24 01:29:11
【问题描述】:
我尝试在我的应用中添加启动画面,虽然它们确实显示在主 Activity 之前,但无论如何该屏幕也始终显示:
这是 MainActivity 的代码:
public class MainActivity extends Activity implements WelcomeFragment.StartQuestions, QuestionFragment.QuestionsAnswered {
@Override
protected void onCreate(Bundle savedInstanceState) {
Parse.enableLocalDatastore(this);
Parse.initialize(this, "***************************", "*****************************");
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
loadingIcon = (ProgressBar) findViewById(R.id.loadingIcon);
loadingIcon.setVisibility(View.GONE);
checkInternetConnection();
showWelcomeScreen();
}
}
showWelcomeScreen():
public void showWelcomeScreen(){
Fragment fragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
if (fragment == null){
fragment = new WelcomeFragment();
getFragmentManager().beginTransaction()
.add(R.id.fragmentContainer, fragment)
.commit();
} else {
fragment = new WelcomeFragment();
getFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment)
.commit();
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" android:id="@+id/loadingIcon"/>
</RelativeLayout>
在 MainActivity 中,我已经指定移除顶栏:
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
应用程序本身没有栏。我在清单中默认放置的任何活动(作为启动屏幕)仍然会在应用启动时通过上面显示的屏幕进行。
【问题讨论】:
-
发布您的主要活动代码。
-
您需要将相关代码添加到您的问题中,以便任何人帮助您
-
对不起。我以为这是每个人的默认屏幕,无论他们的活动代码如何
-
发布
showWelcomeScreen()。 -
developer.android.com/training/system-ui/status.html 这将向您展示如何隐藏状态栏(假设这是您想要做的)。
标签: android android-activity splash-screen