创建和初始化对象的两种方法之一是否更可取?
MyClass oClass = [[MyClass alloc] init];
oClass.length = 5;
oClass.text = @"Hello";
Run Code Online (Sandbox Code Playgroud)
或者使用包含大致相同代码的类方法,但如下所示:
MyClass oClass = [MyClass myClassWithLength:(int) 5 andText:(NSString *) @"Hello"];
Run Code Online (Sandbox Code Playgroud)
当我看到事情不止一种方式而且我不知道一个人比另一个人好,或者为什么时,我讨厌它!
我已经创建了自己的自定义首选项对象来扩展Preference.我只创建了它们,因为这些自定义数据类型没有首选项.
一切正常,但我的自定义首选项没有相同的外观,因为它们缺少系统首选项对象具有的水平分隔符.我已经找到了创建水平分隔符的代码,但我无法找到它的位置.
内置分隔器不仅仅是一个薄条.它有一点渐变.我认为这可能在布局文件中,但我找不到系统首选项的布局.
有人知道这是如何实现的吗?
我有一个自定义类,它扩展了我正在与PreferenceActivity一起使用的Preference.
当我尝试调整我的Preference使用的布局中的高度(使用静态layout_height或使用wrap_content)时,它始终显示在Preference Activity中的统一高度单元格中 - 与所有"普通"首选项默认为相同的大小.
有没有一种方法可以使用不同的layout_height呈现给定的首选项.
我查看了与首选项相关的API演示,但我没有看到任何与我正在尝试的内容相匹配的内容.
Hello当安装应用程序时,它会要求用户发送推送通知的权限.我正在测试我的应用程序.但是从设备中删除后再安装它不再需要许可.如何删除这些设置以便再次请求权限?
我需要它来测试服务器推送通知.
在我的Android应用程序中,我在不同的活动中使用各种自定义主题,所有这些都可以正常工作.所有这些主题都使用相同的自定义样式按钮,编辑控件等.
我的首选项使用标准的首选项活动,我通过清单以XML和样式定义.
但是,当我有一个首选项导致启动警报对话框时,例如ListPreference,该对话框使用标准按钮.它似乎在EditTextPreference中使用我的自定义EditText样式 ...但不是我的背景或文本颜色.
任何人都知道为什么会这样吗?
一些代码:
样式:
<style name="Theme.Prefs" parent="@android:style/Theme.Holo.Light">
<item name="android:windowBackground">@drawable/background</item>
<item name="android:buttonStyle">@style/CustomButtonStyle</item>
<item name="android:editTextStyle">@style/CustomEditTextStyle</item>
</style>
<style name="CustomButtonStyle" parent="@android:style/Widget.Holo.Button">
<item name="android:background">@drawable/custom_button</item>
<item name="android:textSize">@dimen/dialog_text_size_normal</item>
<item name="android:textColor">@color/dialog_control_colour</item>
</style>
<style name="CustomEditTextStyle" parent="@android:style/Widget.Holo.EditText">
<item name="android:background">@drawable/custom_textfield</item>
<item name="android:textColor">@color/dialog_control_colour</item>
<item name="android:textSize">@dimen/dialog_text_size_normal</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在清单中:
<activity
android:name="com.breadbun.prefs.MainPreferencesActivity"
android:theme="@style/Theme.Prefs"
android:screenOrientation="portrait">
</activity>
Run Code Online (Sandbox Code Playgroud) 我试图在xml中为android 调用getIcon一个Preference声明.在所有资源都被夸大之后,我在onCreate为偏好调用它Activity.
图标显示但是如果我这样做findPreference(key)则会调用getIcon并在该首选项上返回的图标是null.
我错过了什么吗?
我注意到:如果Mozilla Firefox用户单击下载链接(EX:this),将弹出以下"打开/保存"对话框窗口:

我rd有用Python编写的下载管理器,所以我需要:
从Firefox获取下载链接.
发送给我的下载管理器.
我想通过以下任何方法实现这一目标:
html但我们应该让用户能够add to/remove from将该文件类型发送到我的应用程序.由于appcompat v7缺失了SwitchCompatPreference,似乎有必要自己创建它.
怎么能实现这一目标?我google了一下,找到了一个教程DialogPreference.我试图采用它,SwitchCompatPreference但在我的xml布局中,它总是说在偏好xml中不允许这个类.
我需要做什么?
我有一个首选项xml文件,在某些时候它看起来像这样:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="Hello there">
<!-- Profile ** -->
<PreferenceScreen
android:key="profile"
android:summary="Let app access my profile info such as name, picture and other account information."
android:title="User Profile">
<CheckBoxPreference
android:defaultValue="true"
android:key="pref_profile"
android:summary="Let app access my profile such as name, picture and other account information."
android:title="My Profile" />
Run Code Online (Sandbox Code Playgroud)
如您所见,我有2个preferenceScreen。我想获取CheckBoxPreference的preferenceScreen(所以带有key的profile屏幕:profile)。当我使用时:
PreferenceScreen prefScreen = getPreferenceScreen();
Run Code Online (Sandbox Code Playgroud)
我得到一个标题为:你好。我如何获得此checkBoxPreference的直接父(第一父)屏幕?我想要得到它,以便我可以禁用或启用其视图。
有什么想法吗?谢谢!!
android preference checkboxpreference preferencescreen android-settings
preference ×10
android ×7
creation ×1
firefox ×1
gradient ×1
icons ×1
ios ×1
iphone ×1
line ×1
object ×1
objective-c ×1
setting ×1
switchcompat ×1
themes ×1
xul ×1