- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有几个自定义的 DialogPreference
实现 float ,例如 this one :
package apt.tutorial;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.TimePicker;
public class TimePreference extends DialogPreference {
private int lastHour=0;
private int lastMinute=0;
private TimePicker picker=null;
public static int getHour(String time) {
String[] pieces=time.split(":");
return(Integer.parseInt(pieces[0]));
}
public static int getMinute(String time) {
String[] pieces=time.split(":");
return(Integer.parseInt(pieces[1]));
}
public TimePreference(Context ctxt) {
this(ctxt, null);
}
public TimePreference(Context ctxt, AttributeSet attrs) {
this(ctxt, attrs, 0);
}
public TimePreference(Context ctxt, AttributeSet attrs, int defStyle) {
super(ctxt, attrs, defStyle);
setPositiveButtonText("Set");
setNegativeButtonText("Cancel");
}
@Override
protected View onCreateDialogView() {
picker=new TimePicker(getContext());
return(picker);
}
@Override
protected void onBindDialogView(View v) {
super.onBindDialogView(v);
picker.setCurrentHour(lastHour);
picker.setCurrentMinute(lastMinute);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
lastHour=picker.getCurrentHour();
lastMinute=picker.getCurrentMinute();
String time=String.valueOf(lastHour)+":"+String.valueOf(lastMinute);
if (callChangeListener(time)) {
persistString(time);
}
}
}
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
return(a.getString(index));
}
@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
String time=null;
if (restoreValue) {
if (defaultValue==null) {
time=getPersistedString("00:00");
}
else {
time=getPersistedString(defaultValue.toString());
}
}
else {
time=defaultValue.toString();
}
lastHour=getHour(time);
lastMinute=getMinute(time);
}
}
它们工作得很好。但是,在定义了 android:targetSdkVersion="11"
的应用程序中,在 XOOM 上,它们在 PreferenceActivity
中显示缺少缩进:
此外,字体大小似乎稍大一些,至少对于标题而言。
DialogPreference
中没有任何内容,我真的覆盖了这些东西的任何格式化行为,AFAIK。偏好 XML 没什么特别的,除了引用上面的类:
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:key="sort_order"
android:title="Sort Order"
android:summary="Choose the order the list uses"
android:entries="@array/sort_names"
android:entryValues="@array/sort_clauses"
android:dialogTitle="Choose a sort order" />
<CheckBoxPreference
android:key="alarm"
android:title="Sound a Lunch Alarm"
android:summary="Check if you want to know when it is time for lunch" />
<apt.tutorial.TimePreference
android:key="alarm_time"
android:title="Lunch Alarm Time"
android:defaultValue="12:00"
android:summary="Set your desired time for the lunch alarm"
android:dependency="alarm" />
<CheckBoxPreference
android:key="use_notification"
android:title="Use a Notification"
android:defaultValue="true"
android:summary="Check if you want a status bar icon at lunchtime, or uncheck for a full-screen notice"
android:dependency="alarm" />
</PreferenceScreen>
有人知道我哪里出错了吗?
谢谢!
更新
Here is a link to a project包含此自定义首选项和演示问题的简单首选项 XML 文件。即使只有两个 Java 类、首选项 XML 和一个 arrays.xml
文件,我也得到了这种现象。 Here is a compiled APK来自这个项目。
最佳答案
(来自 associated android-developers thread 的交叉发布)
好的,我想通了。
Preference 上有三种可能的构造函数:
MyPreference(Context ctxt)
MyPreference(Context ctxt, AttributeSet attrs)
MyPreference(Context ctxt, AttributeSet attrs, int defStyle)
沿着这条线的某个地方,我拿起了模式一参数构造函数链到二参数构造函数(为第二个参数传递 null
),并具有两个参数构造函数链到三参数构造函数(将 0 传递给第三个参数)。
这不是正确的答案。
我希望正确的答案是只实现第二个构造函数,因为正确的默认样式是 Android 内部的(com.android.internal.R.attr.dialogPreferenceStyle
)。第二构造函数是用于膨胀首选项 XML 的。
感谢大家的帮助!
关于android - 自定义首选项,targetSdkVersion ="11": missing indent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5757012/
这很奇怪,我只是在变量设置中进行了更改以使用哈希代替......你知道: black = #000 替换为: colors = { 'black': #000 // and so o
这很奇怪,我只是在变量设置中进行了更改以使用哈希代替......你知道: black = #000 替换为: colors = { 'black': #000 // and so o
我有这行代码,在测试 pep8 错误时我得到:线太长。因此,为了尝试解决此问题,我使用了 slash('\') 但随后我将延续行过度缩进以进行视觉缩进。我该怎么做才能解决这个问题? 我尝试过的事情:
我在下面的代码中收到一个 continuation line under-indented for visual indent 错误: command = 'ffmpeg -i downloa
我就是想不通这是怎么回事…… #!/usr/bin/env python # # Bugs.py # from __future__ import division # No
我是一个 Emacs 用户,在配置编辑器方面没有任何技能。我从 haskell-mode 升级后从 2.4 到 2.7,我注意到两个变化: 缩进在某种程度上是不同的,在某种程度上我不太喜欢。我不能完全
我正在尝试制作一个嗅探DNS数据包的程序,然后将数据包的qname放入字典的“键”中,并将数据包的dst ip放入字典的“值”中,由于某种原因,我遇到了此错误在第6行 from scapy.all
为了进行比较: 在Sublime(以及Atom)中,如果我在已经有4个制表符空间的代码行下按Tab,Sublime将自动跳到上一行的相同制表符间距(4个制表符空间)。 在VS Code中,当尝试完成相
无论我以哪种方式编写以下函数都会引发错误。 @staticmethod def _generate_clone_spec(param1=None, p
我正在 Sublime 文本编辑器中使用 Python。我被添加PEP8 packages . 我将 128 添加到以下文件“pep8_ignore”中。添加128并保存后。 Preferences
我从这里得到了 Google java 风格: https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style
刚刚使用 Sublime Text(使用 Sublime Linter)打开了一个文件,并注意到我以前从未见过的 PEP8 格式错误。正文如下: urlpatterns = patterns('',
我已安装 google-java-format插件 IntelliJ我已经启用了插件。当我格式化代码时,我的 java 代码缩进了 2 个空格。如何将 google java 格式化程序插件设置更改为
Haskell Parsec 的 indents 包提供了一种解析缩进式语言(如 Haskell 和 Python)的方法。它重新定义了 Parser类型,那么如何使用 Parsec 的 Text.P
我想让我的代码更有条理。因此,每当我从我的functions.php 文件中复制一个函数并将其粘贴到一个类中时,我需要将函数的每一行缩进一次或多次,以便于阅读并且看起来更美观。我的一些函数只不过是巨大
我直接从教科书中复制了这个 block ,并收到许多错误消息,但我无法解决其中的任何一个。我已经阅读并重读了我书中的这一部分,据我所知,这都是一个 block ,所以我很困惑为什么会有意外的缩进。我将
我直接从教科书中复制了这个 block ,并收到许多错误消息,但我无法解决其中的任何一个。我已经阅读并重读了我书中的这一部分,据我所知,这都是一个 block ,所以我很困惑为什么会有意外的缩进。我将
我一直在尝试找到一种也适合回溯缩进的递归下降解析器算法。但我一直让自己为此寻找麻烦的解决方案。 是否有任何资源也可以处理缩进? 谢谢 最佳答案 根据您的问题,我假设您正在为缩进敏感语言编写自己的递归下
有时,当我在 Sublime text2 中编辑 coffeescript 文件时,将其编译为 js 时出现错误: error: unexpected INDENT
我的main.sass中有这个: #thing { -moz-box-sizing: border-box; -webkit-box-sizing: border
我是一名优秀的程序员,十分优秀!