preferenceactivity

Is it possible to customize preference-header layout?

删除回忆录丶 提交于 2019-12-05 04:48:32
I have found similar questions, but can't find a specific answer that is up-to-date. I'm using <preference-header> , as per 3.0+ settings design guidelines ( I target 4.1.2+) to build my headers; I want to set a custom layout to these headers. Note that I don't want to fall back to the old PreferenceScreen method as described here , because I don't support older Android version. As far as I could research, this layout is held by a private member of the PreferenceActivity class, and it's retrieved with a styleable attribute that doesn't seem publicly accessible: private int

Google Play services resources were not found. 'AdsMob'

隐身守侯 提交于 2019-12-05 03:56:32
问题 I am getting this error when I try to load and InterstitialAd from google AdMob. I know that I have written the code correctly. As I followed the short tutorial on https://developers.google.com/mobile-ads-sdk/docs/admob/advanced#play All the happens is I get and error in the Logcat. What might I be doing wrong. Here is the code: public class Pref extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener { /** The view to show the ad. */ private AdView adView; /*

订制属于你自己的PreferenceActivity

孤者浪人 提交于 2019-12-05 01:12:56
当我们想给我们的应用给一个设置页面的时候,我第一反应就想到了PreferenceActivity,但我们小组的头说系统默认的PreferenceActivity不符合客户的需求,我不甘心,就开始自己在网上寻找资料,订制一个想要的PreferenceActivity页面。 功夫不负有心人,经过了2天的奋斗终于出了成果,也很感谢网上那些分享成果的哥们,他们让我受益良多。 下面是我自己订制的PreferenceActivity的效果: 外面整个是一个PreferenceScreen,里面包裹了5个Preference,前两个是继承了CheckBoxPreference,第三个是继承了ListPreference,最后两个是继承了普通的Preference,不过为它们专门添加了点击事件。 背景是白色的,代码如下: this.getListView().setBackgroundResource(R.drawable.preference_background); 因为PreferenceActivity其实是继承了ListActivity的,而它加载的整个View也是基于ListActivity中那个ListView的,所以直接设置就可以了,不过好像使用setBackgroundColor()这个方法没有效果,我也没搞明白,有大神帮忙解答一下。 我在下面是我在res

PreferenceActivity的使用

不羁的心 提交于 2019-12-05 01:12:46
preferenceActivity ,这个 activity 是方便用于做一些配置界面的,像 android 系统中也是大量的使用到了 preferenceActivity ,比如设置里面的带 checkBox 勾选框的那些设置,也可以做列表选项,用起来很方便,也便于管理 具体使用方法:创建一个类继承 preferenceActivity , 最主要的是要创建一个 xml 文件,现在 res 里面创建一个 xml 的文件夹,然后创建 xml 文件可以去 API 文档里面看实例代码 展示出来的效果如下: 来源: oschina 链接: https://my.oschina.net/u/1024921/blog/120106

Android: add buttons to a preference screen

旧巷老猫 提交于 2019-12-04 20:09:58
The thing is...I want to use PreferenceActivity to add a new row in my custom list view. So my preference ativity will consist of a few EditTextPreferences, my custom TimePickerPreference and a coulpe of ListPreferences... Like this: http://www.google.com/help/hc/images/android/android_ug/168567.5.png . The question is how they added buttons on the bottom? And.. is it possible to use OnClickListener for obtaining inputed values and how? Thanks! A PreferenceActivity inherits from ListActivity . By default, ListActivity creates its own ListView , but you can supply your own layout via

start an other PreferenceScreen through a PreferenceActivity option

匆匆过客 提交于 2019-12-04 19:42:13
I'm writing a configuration menu with many options and I'd like to add in the main PreferenceScreen an option that can launch an other PreferenceScreen. I can't figure out how to create a generic menu entry (so, nor EditTextPreference nor CheckBoxPreference etc.) Thanks to all. Nest your PreferenceScreen elements. The inner PreferenceScreen will hold the contents of the second screen; the title and description you put on the inner PreferenceScreen will be your "generic menu entry". For example: <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory

Dynamically create CheckBoxPreferences

落爺英雄遲暮 提交于 2019-12-04 18:40:33
问题 I am currently building out a list of rows with checkboxes dynamically using content from a web service. However, this ListView will need to do pretty much what a PreferenceActivity would accomplish. I don't know the number of rows as the content is dynamic so I can't create each CheckBoxPreference in XML. How do I go about building a PreferenceActivity that will display an unknown number rows with a CheckBoxPreference dynamically? 回答1: I think you're looking for something like this: public

how to access widgets set in layout using preference activity

ぃ、小莉子 提交于 2019-12-04 15:52:36
i am creating preference Activity, in that i am adding custom preference screen using layout and i want to update values dynamically. Here's the code : <PreferenceCategory android:key="more_category" android:title="More Wallpapers " > <Preference android:key="more_apps" android:layout="@layout/more_apps" /> Here is my layout more_apps.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:padding="5dp" android:layout_height="match_parent" > <TextView android:id="@+id/title_text" android

android - How to set custom layout for PreferenceActivity in Android 3.0?

若如初见. 提交于 2019-12-04 10:11:52
问题 I am developing app with minSdkVersion="11", that is app for tablets and Android 4.0 and newer. I have scrutinized internet on this topic, but have not found much. To implement custom layout for previous versions of Android SDK we just have to create layout (say preference.xml) with ListView and its id equals to android.R.id.list and use setContentView method. preference.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

Android Back Button Doesn't Return to Previous Activity

痴心易碎 提交于 2019-12-04 07:59:54
问题 I have an app that has two activities: MainActivity and SettingsActivity. The MainActivity has a menu with a single Settings menu item. When this menu item is clicked, it launches the SettingsActivity with an intent. After the activity starts up, I click the back button in the top left corner and nothing happens. I assumed since I started the activity using an intent, the activity stack would be managed automatically. I want to return to the MainActivity. Am I wrong in this assumption?