android.util.AndroidRuntimeException: You cannot combine custom titles with other title features .



报错】android.util.AndroidRuntimeException: You cannot combine custom titles with other title features

造成这个出错的原因是因为在代码中使用了:

[java]  view plain copy
  1. this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);  
[java]  view plain copy
  1. this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);  
原因应该所在android3.0以上的版本中已经默认帮你设这了title,而在3.0以下的版本可以正常使用,

解决办法就是:

1。在AndroidManifest.xml 中更改<application>标签中的android:theme="@style/AppTheme"(自定义主题时候),根据自己需要更改。

2。或者直接删除掉\res\values-v11和v11+(系统默认的对你没有用处时)。





=======================================================================================================


android4.0以后使用自定view来自定义设置标题

ActionBar actionBar = this.getActionBar();
actionBar.setCustomView(R.layout.title_bar);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.show();

根据提供的引用内容,你遇到了一个Android运行时异常:Android.Util.AndroidRuntimeException: 'Only the original thread that created a view hierarchy can touch its views.' 这个异常通常在多线程操作UI界面时出现。在Android中,只有创建视图层次结构的原始线程才能访问和修改视图。 为了解决这个问题,你可以使用以下方法之一: 1. 使用runOnUiThread()方法:这个方法允许你在非UI线程中更新UI。你可以在需要更新UI的地方调用runOnUiThread()方法,并在其中执行UI操作。 ```java runOnUiThread(new Runnable() { public void run() { // 在这里执行UI操作 } }); ``` 2. 使用Handler类:Handler类允许你在非UI线程中发送和处理消息。你可以在非UI线程中创建一个Handler对象,并使用它发送消息到UI线程,然后在UI线程中处理这些消息来更新UI。 ```java Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { public void run() { // 在这里执行UI操作 } }); ``` 3. 使用AsyncTask类:AsyncTask类是Android提供的一个方便的类,用于在后台线程执行异步任务,并在UI线程中更新UI。你可以继承AsyncTask类,并在doInBackground()方法中执行后台任务,在onPostExecute()方法中更新UI。 ```java private class MyTask extends AsyncTask<Void, Void, Void> { protected Void doInBackground(Void... params) { // 在这里执行后台任务 return null; } protected void onPostExecute(Void result) { // 在这里更新UI } } // 在非UI线程中执行任务 new MyTask().execute(); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值