preferenceactivity

How to setOnTouchListener() on a ListPreference?

北城以北 提交于 2019-12-01 18:21:28
Handling onTouchEvent on a view is straightforward as every view has the setOnTouchListener() method to do just that. Alas, although ListPreference is a view, it isn't defined in a layout XML, and thus can't be accessed via findViewById(). So... I don't seem to figure out how to setOnTouchListener() for it. My idea was to get a reference to it in PreferenceActivity's onCreate(), then getDialog(). getCurrentFocus() but at that particular moment in time, it has no focus and not even a dialog (getDialog() returns null, confirmed). Any idea how to work around this? Use

How to setOnTouchListener() on a ListPreference?

孤人 提交于 2019-12-01 18:14:11
问题 Handling onTouchEvent on a view is straightforward as every view has the setOnTouchListener() method to do just that. Alas, although ListPreference is a view, it isn't defined in a layout XML, and thus can't be accessed via findViewById(). So... I don't seem to figure out how to setOnTouchListener() for it. My idea was to get a reference to it in PreferenceActivity's onCreate(), then getDialog().getCurrentFocus() but at that particular moment in time, it has no focus and not even a dialog

Preferences of varying height within a PreferenceActivity

给你一囗甜甜゛ 提交于 2019-12-01 17:43:53
I have a custom class that extends Preference that I'm using in conjunction with a PreferenceActivity. When I try to adjust the height in the layout my Preference is using (with a static layout_height or with wrap_content) it is always displayed in a uniform height cell in the Preference Activity - the same size that all of the "normal" preferences default to. Is there a way present a given preference with a different layout_height. I've looked at the API demos related to preferences and I'm not seeing anything that matches what I'm trying to do. theJosh You can override getView(View,

usage of findviewbyid in preferenceactivity

為{幸葍}努か 提交于 2019-12-01 15:07:03
问题 I have a preference screen and i am specifying a layout resource using the android:layout attribute. In the preference activity i am using/inflating the preference using addPreferencesFromResource from onCreate method. Inside the layout i have few textviews and buttons. The problem is i am unable to find any of the textviews, checkboxes and buttons using findViewById method ! Every result for findViewById returns null. EDIT : I need to attach a listener to the checkbox. Can anyone please help

Start activity from preference-headers

帅比萌擦擦* 提交于 2019-12-01 03:54:30
I'm implementing n-layer PreferenceActivities 1st layer PreferenceActivity is loaded from preference-headers. First header creates fragment of settings which is a PreferenceFragment. Second is a browser activity (2nd is an example from developer.android.com) which opens specified Url. The third one I want to be a next level of PreferenceAtivity that also will be loaded from preference-headers. First two work fine but 3rd is crashing an app with the exception: "android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=com.mycompany.myapp

Android Listen For Change in GPS Status?

和自甴很熟 提交于 2019-12-01 01:44:06
Hello I need to know how to listen for the following with the GPS in Android so I can update the UI in a PreferenceActivity . I have tried GpsStatus.Listener with nothing happening. GpsStatus.GPS_EVENT_STARTED GpsStatus.GPS_EVENT_STOPPED Any suggestions would be great. mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates mGPSStatusListener = new GpsStatus.Listener() { public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: satelliteStatus = mLocationManager

Reload Preferences in PreferenceActivity on Resume

江枫思渺然 提交于 2019-11-30 18:49:22
In my app, some settings can possibly be changed while the PreferenceActivity is not open, and an issue I'm running into is that addPreferencesFromResource is called in onCreate , so say, I open the PreferenceActivity , then go to another screen from there, then do something that changes the settings, then hit the back key to go back to the PreferenceActivity , then certain settings have not changed on the layout. So, how could I re-load all the Preferences every time onResume (or onStart() ) is called without duplicating the layout? edit: This solution will work for API 11 + only. Im not sure

add action bar with back button in preference activity [duplicate]

浪子不回头ぞ 提交于 2019-11-30 18:16:43
This question already has an answer here: Creating a Preference Screen with support (v21) Toolbar 13 answers Here is my preference activity: package com.example.hms.test; import android.os.Bundle; import android.preference.PreferenceActivity; public class PrefsActivity extends PreferenceActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); } } here I want to show an actionbar with name settings and a back button to home Pooya You should do couple of things: Add the following to your onCreate of

How to apply theme to <PreferenceScreen> elements of a <PreferenceCategory>

霸气de小男生 提交于 2019-11-30 15:40:30
问题 I have an activity that extends PreferenceActivity. My theme : android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" is applied to the application level in the Manifest file. Everything is getting the desired theme except the "PreferenceScreen" elements of "PreferenceCategory". They are still having the default black background. In simple words, the main Preference Category screen which has the parent Preference Screens are getting the theme but if I click on any of the

How to apply theme to <PreferenceScreen> elements of a <PreferenceCategory>

我与影子孤独终老i 提交于 2019-11-30 15:01:34
I have an activity that extends PreferenceActivity. My theme : android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" is applied to the application level in the Manifest file. Everything is getting the desired theme except the "PreferenceScreen" elements of "PreferenceCategory". They are still having the default black background. In simple words, the main Preference Category screen which has the parent Preference Screens are getting the theme but if I click on any of the PreferenceScreens to go to their element preferences(EditText etc etc), they are not getting the theme... Any Idea