Android的:如何隐藏动作条上的某些活动 [英] Android: how to hide ActionBar on certain activities

查看:107
本文介绍了Android的:如何隐藏动作条上的某些活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个闪屏的地图和一些常规的屏幕一个简单的演示应用程序。

我在一个包含一个标志顶部的操作栏。这一切都看起来很好,在我的手机(银河S1 I9000 V2.3),但是当我测试它的GALAXY S2 V4的操作栏也出现在开机画面和地图画面。

在spalsh和地图的活动,甚至没有从ActionBarActivity继承这样怎么可能,我怎么可以让它消失?

清单:

 <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:主题=@风格/ Theme.AppCompat.Light>
        <活动
            机器人:HomeActivityNAME =
            机器人:图标=@可绘制/ android_logo
            机器人:标签=
            机器人:标志=@可绘制/ android_logo>

            <! - 
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
             - >
        < /活性GT;
        <活动
            机器人:名称=。MapActivity
            机器人:标签=>
        < /活性GT;
        <活动
            机器人:名称=。PackageActivity
            机器人:图标=@可绘制/ android_logo
            机器人:标签=
            机器人:标志=@可绘制/ android_logo>
        < /活性GT;
        <活动
            机器人:名称=。SplashActivity
            机器人:标签=>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;

    < /用途>
 

MapActivity定义(这是一个漫长的,所以我只包含的定义):

 公共类MapActivity扩展FragmentActivity实现LocationListener的
 

飞溅活动:

 进口android.app.Activity;
进口android.content.Intent;
进口android.os.Bundle;
进口android.os.Handler;
进口android.support.v7.app.ActionBar;
进口android.support.v7.app.ActionBarActivity;

公共类SplashActivity延伸活动{

    私有静态最后长SPLASH_DISPLAY_LENGTH = 2000;

    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_splash);

        新的处理程序()。postDelayed(新的Runnable(){
            @覆盖
            公共无效的run(){
                意图mainIntent =新的意图(SplashActivity.this,HomeActivity.class);
                SplashActivity.this.startActivity(mainIntent);
                SplashActivity.this.finish();
            }
        },SPLASH_DISPLAY_LENGTH);

    }

}
 

解决方案

应用在主题为活动按照的Andr​​oidManifest.xml

 <活动机器人:名称=活动
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@安卓风格/ Theme.NoTitleBar>
    <意向滤光器>
        <作用机器人:名称=android.intent.action.MAIN/>
        <类机器人:名称=android.intent.category.LAUNCHER/>
    &所述; /意图滤光器>
< /活性GT;
 

这是应该做的伎俩。

I've developed a simple demo application with a splash screen a map and some regular screens.

I have an action bar at the top that contains a logo. It all looks fine on my phone (Galaxy s1 I9000 V2.3) but when i test it on Galaxy s2 v4 the action bar appears also in the splash screen and in the map screen.

The spalsh and map activity are not even inheriting from ActionBarActivity so how is that possible and how can i make it go away?

Manifest:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/Theme.AppCompat.Light" >
        <activity
            android:name=".HomeActivity"
            android:icon="@drawable/android_logo"
            android:label=""
            android:logo="@drawable/android_logo" >

            <!--
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            -->
        </activity>
        <activity
            android:name=".MapActivity"
            android:label="" >
        </activity>
        <activity
            android:name=".PackageActivity"
            android:icon="@drawable/android_logo"
            android:label=""
            android:logo="@drawable/android_logo" >
        </activity>
        <activity
            android:name=".SplashActivity"
            android:label="" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    </application>

MapActivity definition (it's a long one so i included just the definition):

public class MapActivity extends FragmentActivity implements LocationListener

Splash Activity:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;

public class SplashActivity extends Activity{

    private static final long SPLASH_DISPLAY_LENGTH = 2000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable(){
            @Override
            public void run() {
                Intent mainIntent = new Intent(SplashActivity.this,HomeActivity.class);
                SplashActivity.this.startActivity(mainIntent);
                SplashActivity.this.finish();
            }
        }, SPLASH_DISPLAY_LENGTH);

    }

}

解决方案

Apply the following in your Theme for the Activity in AndroidManifest.xml:

<activity android:name=".Activity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

That should do the trick.

这篇关于Android的:如何隐藏动作条上的某些活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆