19

スプラッシュ画面の動作のためのアクションバーを非表示にする方法を理解しようとしています。 スプラッシュ画面にアクションバーを隠すようなことをしましたが、問題が1つあります: スプラッシュ画面が表示される前に、簡単に表示されるアクションバーのアクティビティがありますそれを隠す!スプラッシュ画面アプリケーションと非表示のアクションバー

私のスプラッシュ画面は、アプリケーションの紹介のように初めてアプリケーションに触れるときにのみ表示されます。

コード:

package com.example.basicmaponline; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.Window; 

public class Intro extends Activity{ 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 


    getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 
    getActionBar().hide(); 

    setContentView(R.layout.intro); 

    Thread timer = new Thread(){ 
     public void run(){ 
      try{ 
       sleep(3000); 
      }catch (InterruptedException e) { 
       e.printStackTrace(); 
      }finally{ 
       Intent openMenu = new Intent("com.example.basicmaponline.MENU"); 
       startActivity(openMenu); 
      } 
     } 
    }; 
    timer.start(); 
} 

@Override 
protected void onPause() { 
    // TODO Auto-generated method stub 
    super.onPause(); 
    finish(); 
} 

} 

マニフェスト:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.basicmaponline" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="17" /> 
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_GPS"></uses-permission> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/lojacidadao" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name="com.example.basicmaponline.Intro" 
     android:screenOrientation="portrait" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.Menu" 
     android:screenOrientation="portrait" 
     android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.MENU" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.Mapa" 
     android:screenOrientation="portrait" 
     android:label="@string/map_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.MAPA" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name="com.example.basicmaponline.Lojas" 
     android:screenOrientation="portrait" 
     android:label="@string/lojas_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.LOJAS" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.InfoLoja" 
     android:screenOrientation="portrait" 
     android:label="@string/loja_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.INFOLOJA" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.Balcoes" 
     android:screenOrientation="portrait" 
     android:label="@string/balcoes_name" > 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.BALCOES" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.Entidade" 
     android:screenOrientation="portrait" 
     android:label="@string/balcao_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.ENTIDADE" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.Servicos" 
     android:screenOrientation="portrait" 
     android:label="@string/servicos_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.SERVICOS" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.InfoServico" 
     android:screenOrientation="portrait" 
     android:label="@string/servico_name"> 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.INFOSERVICO" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name="com.example.basicmaponline.Pesquisar" 
     android:screenOrientation="portrait" 
     android:label="@string/pesquisa_name" > 
     <intent-filter> 
      <action android:name="com.example.basicmaponline.PESQUISAR" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

</application> 
</manifest> 
+0

@rciovati。最初にレイアウト内にそれを設定しないと、ちらつきとして記述するのが問題ではありません。 –

+0

投稿マニフェスト – Blackbelt

+0

私のマニフェストを追加しました:) – Damiii

答えて

45

アクションバーを除外する最初のアクティビティのテーマと、おそらく通知バーを明示しますか?

何かのように:アプリケーション・タグで、それを持っているデフォルトのテーマを設定しているので、それはあなたの前の活性はないので

<application 
    android:allowBackup="true" 
    android:icon="@drawable/lojacidadao" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name="com.example.basicmaponline.Intro" 
     android:screenOrientation="portrait" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
... 

ところで、あなたはアクションバーを持っている理由は、それは本当にですあなた自身のスプラッシュアクティビティ。

+1

それは働いた!ありがとうございました ! "android:theme =" @アンドロイド:style/Theme.NoTitleBar。Androidの "android:Theme.Holo"は、各アクティビティのアクションバーを表示します。Ok!:) – Damiii

+0

はい、古いAndroidバージョン(gingerbread以下)にアクションバーを追加することをサポートしたい場合は、 –

+0

ok!:)ありがとう!:) – Damiii

2

あなたが問題だ、まったく呼び出すために何ActionBarがあってはならないとして、彼らが必要とされていないこれらの線が

getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 
getActionBar().hide(); 

です、スプラッシュ画面は1つを使用せず、完全に別のものにする必要がありますActivity thaあなたの他人。

2つが必要ですActivitiesスプラッシュスクリーンのための1つはそれ自身のレイアウトです。第二には、ログイン画面またはようこそ画面など

スプラッシュスクリーンクラスが

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/LinearLayout1"  
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gravity="center" 
android:orientation="vertical"  
tools:context=".SplashScreen" > 

// if not using an image replace with whatever is to be shown on the splash screen 
<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/logo" /> 

</LinearLayout> 

今、この

public class SplashScreen extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

    setContentView(R.layout.yourlayoutfile); 

    Thread loading = new Thread() { 
     public void run() { 
      try { 
       sleep(5000); 
       Intent main = new Intent(SplashScreen.this, Main.class); 
       startActivity(main); 
      } 

      catch (Exception e) { 
       e.printStackTrace(); 
      } 

      finally { 
       finish(); 
      } 
     } 
    }; 

    loading.start(); 
} 

} 

XMLファイルのようになりますすることができ、メインActivity、ためのものです第2 ActivityActionBarなどのレイアウトを持っています。

+0

私はあなたのやったことと同じことをしました...私は自分のアプリケーションに触れて、アクティビティバーで簡単に(半分)表示され、 f – Damiii

+0

これは実際のデバイスか 'AVD'で起こっていますか? –

+0

私は私のsamsung銀河s4とそれをやっている – Damiii

3

ビルドターゲットSDK 5.0以上(AppThemeスタイルはTheme.AppCompat.Light.DarkActionBarである。)場合、私は二本の意見でしょう

<activity 
    android:name=".Splash" 
    android:label="@string/app_name" 
    android:theme="@style/Theme.AppCompat.Light.NoActionBar"> 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
</activity> 
関連する問題