我有一个菜单项在android 4.x上显示但不在2.x上显示.这是我的menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/menu_filter"
android:title="Filter"
app:showAsAction="always"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
这是我的动作栏样式
<style name="style1_actionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/blue_dark</item>
<item name="android:textColor">@color/white</item>
<item name="actionMenuTextAppearance">@color/white</item>
<item name="background">@color/blue_dark</item>
</style>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
编辑:删除双引号拼写错误
可能是因为我只显示文字,没有图标吗?我有点被困在这里.
我想把我的所有样式放到我的应用程序的主题中.但是,我在TextView上更改textColor时遇到了问题.这是来自我的attrs.xml文件.
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<declare-styleable name="flat">
<attr name="detail_name_view" format="reference" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
这是来自我的styles.xml文件
<style name="flat_theme" parent="android:Theme.NoTitleBar">
<item name="detail_name_view">@style/flat_detail_name</item>
</style>
<style name="flat_detail_name" parent="@android:style/Widget.TextView">
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textColor">@color/detail_group_black</item>
<item name="android:textSize">16sp</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是来自我的layout.xml文件
<TextView
android:id="@+id/detail_name"
style="?detail_name_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:gravity="left|center_vertical" />
Run Code Online (Sandbox Code Playgroud)
我还使用以下内容正确设置了清单.
<application
android:name="com.example.blah"
android:icon="@drawable/blah"
android:label="@string/app_name"
android:theme="@style/flat_theme"
Run Code Online (Sandbox Code Playgroud)
颜色永远不会变为"@ color/detail_group_black".我错过了一些简单的事吗?或者问题是Android已经为TextView创建了一个textColor属性,这就是为什么样式没有覆盖它?我的属性主题策略似乎适用于应用程序的其余部分但不是这个.有任何想法吗?提前致谢.
此外,如果它可以帮助我宁愿不为这个改变创建一个自定义TextView类:它是一个相当大的项目,我不知道如果我扩展TextView的一切可能会遇到什么样的问题.
编辑 此外,如果我将TextView更改为style ="@ style/flat_detail_name_view",它可以正常工作.我不想这样做的原因是我可以通过更改主题来更改这些文本视图的外观.使用style ="?something_else"适用于我所有的其他视图,所以我真的不明白这一点,我可能会遗漏一些简单的东西?
我一直在阅读一些关于算法的旧书和学习各种类型的书.看起来所有最快的排序算法都在大约O(nLogn)时间运行,它让我想到为什么这是我们能做的最好的?我写了另一种似乎在某些情况下运行得更好的算法(除非我错过了什么),但在其他情况下却非常糟糕.这已经是一个正在使用的算法,我只是在这里重新发明轮子?
public class Main {
public static void main(String[] args) {
// array sort looks like it performs best in this example.
// this is because N is pretty close in value to (max - min) in the array
int[] arr = { 5, 26, 3, 32, 27, 9, 24, 29, 6, 37, 16, 10, 12, 28, 31, 22, 8, 20, 18, 2, 35, 14, 36, 7, 4, 15, 21};
arraySort(arr);
for (int i = 0; i < arr.length; i++) …
Run Code Online (Sandbox Code Playgroud)