android 新建项目中去掉标题栏
1.新建new android application project
theme选none 并打钩创建一个Blank Activity
运行如下图所示:

2。若想把标题栏去掉,更改Manifestr的MainActivity 主题样式
>styles.xml中改
开始将<style name="AppTheme" parent="AppBaseTheme">
改为:<style name="AppTheme" parent="android:Theme.Light.NoTitleBar">//无标题白色背景
去行,闪退并报错:Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
3。原因,是由于public class MainActivity extends ActionBarActivity在创建的时候继承了ActionBarActivity有标题的类,这样就会报错
更改继承FragmentActivity并把相应提示报错处理一下就可以。
具体代码如下:
package com.example.abc; import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build; public class MainActivity extends FragmentActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
} // @Override
// public boolean onCreateOptionsMenu(Menu menu) {
//
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
//
// @Override
// public boolean onOptionsItemSelected(MenuItem item) {
// // Handle action bar item clicks here. The action bar will
// // automatically handle clicks on the Home/Up button, so long
// // as you specify a parent activity in AndroidManifest.xml.
// int id = item.getItemId();
// if (id == R.id.action_settings) {
// return true;
// }
// return super.onOptionsItemSelected(item);
// } /**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment { public PlaceholderFragment() {
} @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
} }
运行正确:

android 新建项目中去掉标题栏的更多相关文章
- android在activity中去掉标题栏
package com.goodness.goodness; import android.support.v7.app.AppCompatActivity; import android.os.Bu ...
- android应用中去掉标题栏的方法
现在我坚定的认为写技术博客对自己有很大的帮助,写博客给自己一个学而思的机会. 在Android中去掉标题栏有三种方法,它们也有各自的特点. 1.在代码里实现 this.requestWindowFea ...
- android开发之---文字居中---android中去掉标题栏
1. 让textView里面的内容水平居中 : android:gravity="center_horizontal" 2. 让textView控件在它的父布局里水平居中 ...
- 去掉Android新建项目的顶部标题
[ 去掉Android新建项目的顶部标题] 使用NoActionBar的Theme即可. 参考:http://blog.csdn.net/u012246458/article/details/5299 ...
- Android中去掉标题栏
在Android中去掉标题栏有三种方法,它们也有各自的特点. 1.在代码里实现 this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 记 ...
- 如何在Android Studio项目中导入开源库?
前两天,谷歌发布了Android Studio 1.0的正式版,也有更多的人开始迁移到Android Studio进行开发.然而,网上很多的开源库,控件等还是以前的基于Eclipse进行开发,很多人不 ...
- Jenkins新建项目中源码管理Repository URL使用Git报错:Failed to connect to repository : Command "git ls-remote -h......
之前部署了Gitlab+Gerrit+Jenkins持续集成环境,但在Jenkins中新建项目的源码管理"Repository URL"中添加git地址环节出现了问题,信息为&qu ...
- Android Studio 项目中集成百度地图SDK报Native method not found: com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create:()I错误
Android Studio 项目中集成百度地图SDK报以下错误: java.lang.UnsatisfiedLinkError: Native method not found: com.baidu ...
- 【转】android新建项目时 出现appcompat_v7工程错误和红色感叹号
原文网址:http://www.cnblogs.com/xiaozhang2014/p/4109856.html 最近初学android,版本是22.6.0的话,每次创建一个项目就会出现一个appco ...
随机推荐
- No.014:Longest Common Prefix
问题: Write a function to find the longest common prefix string amongst an array of strings. 官方难度: Eas ...
- ahjesus 单词单数-复数相互转换C#
看codesmith内置的模板在生成存储过程的时候有单复数的转换,用相同的函数名实现了一个 public static class StringUtil { /// <summary> / ...
- 【转】ubuntu源码编译安装php常见错误解决办法
./configure -prefix=/usr/local/php -with-config-file-path=/etc -with-mysql=mysqlnd -with-mysqli=mysq ...
- ReportingServies——SQLServer报表开发综合实例
如果我们安装了sqlserver2008 R2,将会自动安装一个报表开发工具 不要以为此报表开发工具只适合于sqlserver2008,其实在sqlserver2012中也是支持的,事实上我现在项目中 ...
- hibernate 入门([数据访问中间件] 开源框架)
1.内容: hibernate 也是一个经典的[数据访问中间件] 开源框架. 2.hibernate核心组件 SessionFactory[整个数据的操作]重量级组件 ...
- 虚拟机克隆以后出现“需要整合虚拟机磁盘”的解决方法
问题描述 在虚拟机克隆完毕以后,原始虚拟机提示"需要整合虚拟机磁盘" 在"任务与事件"栏中看到以下信息 解决方法 从上面可以看到是因为整合失败导致的,那么我们只 ...
- Android studio .gitignore 文件的内容
# built application files *.apk *.ap_ # files for the dex VM *.dex # Intellij project files .idea/ . ...
- 最近项目用到Dubbo框架,临时抱佛脚分享一下共探讨。
1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果没有分布式的需求,其实是不需 ...
- php中的curl
/** * 请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ipost [ ...
- 1.8 基础知识——GP2.7 识别和卷入干系人(Stakeholder) & GP2.9 质量保证(QA)
GP2.7 识别和卷入干系人(Stakeholder) GP2.7 Identify and involve the relevant stakeholders of XXX process as p ...