Android应用程序操作栏未显示4.3版本.. [英] Android application action bar not showing on 4.3 version..

查看:41
本文介绍了Android应用程序操作栏未显示4.3版本..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试我制作的应用程序,操作栏适用于我的4.4版本。 4.3版本中未显示该栏。



这就是我正在使用的:



I have been trying out an application I made and the action bar works on my 4.4 version. The ation bar doesn't show on the 4.3 version.

This is what I'm using:

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

< br $>






private static final int ABOUTUS = Menu.FIRST + 1;

private static final int CLOSE = Menu.FIRST + 2;





@Override

protected void onCreate (Bundle savedInstanceState){

// TODO自动生成的方法存根

super.onCreate(savedInstanceState);

setContentView(R.layout。 activity_main);

}



@Override

public boolean onCreateOptionsMenu(菜单菜单){

menu.add(Menu.NONE,ABOUTUS,Menu.NONE,关于我们);

menu.add(Menu.NONE,CLOSE,Menu.NONE,退出) ;



返回(super.onCreateOptionsMenu(菜单));

}



@Override

public boolean onOptionsItemSelected(MenuItem item){

switch(item.getItemId()){

case ABOUTUS:

Intent intent = new Intent(this,AboutUs.class);

startActivity(intent);

break ;

案例关闭:

完成();

休息;



默认值:

完成();

休息;

}

return(super.onOptionsItemSelected(item)) ;

}



}



我在我的网站上输入了appcombat_V7工作区。



不确定为什么会这样,但收到的任何帮助将不胜感激。





private static final int ABOUTUS = Menu.FIRST + 1;
private static final int CLOSE = Menu.FIRST + 2;


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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, ABOUTUS, Menu.NONE, "About Us");
menu.add(Menu.NONE, CLOSE, Menu.NONE, "Exit");

return (super.onCreateOptionsMenu(menu));
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case ABOUTUS:
Intent intent = new Intent(this, AboutUs.class);
startActivity(intent);
break;
case CLOSE:
finish();
break;

default:
finish();
break;
}
return (super.onOptionsItemSelected(item));
}

}

I have the appcombat_V7 imported in my workspace.

Not really sure why this is happening but any help received will be much appreciated.

推荐答案

首先,在使用AppCompat ActionBar的活动中,您需要导入必要的类。



Firstly, in the activities that use the AppCompat ActionBar you need to import the necessary classes.

import android.support.v7.app.ActionBarActivity;
   import android.support.v4.app.Fragment;
   import android.support.v7.app.ActionBar;

//如果你需要自定义ActionBar



其次,每个* activity *都必须扩展ActionBarActivity类。 />


//说

//if you need to customize the ActionBar

Secondly, each *activity* must extend the ActionBarActivity class.

//say

public class MainActivity extends ActionBarActivity {





第三,你需要在各种值/值-v11文件夹中的styles.xml文件中声明正确的主题。





Thirdly, you need to declare the right theme in the styles.xml files in the various values/values-v11 folders.

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
       <!--



更新的API级别提供的主题自定义可以在

res / values- vXX / styles.xml,与

向后兼容相关的自定义可以在这里进行。

- >

< / style>



对于* styles.xml * in ** values-v14 **文件夹:




Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

For *styles.xml* in **values-v14** folder :

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>





如果你已经用这种方式做过,那么我想补充说基本的使用* New创建的模板 - >其他 - > Android - > Android应用程序项目*选项和设置android:minSdkVersion =8适用于Android 4.3在模拟器和设备上。我已对此进行了测试,并建议您将其作为参考。



If you have done things this way already, then I would like to add that the basic template created using the *New -> Other -> Android -> Android Application Project* option and setting the android:minSdkVersion="8" works well with Android 4.3 on the emulator and on devices. I have tested this and suggest you use this as a reference.


这篇关于Android应用程序操作栏未显示4.3版本..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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