Android :: Setting UI Preference Summary Field To Value

Sep 30, 2010

New to Android, I have some code when the user changes a preference I update the Summary field in the UI preference to be the value they entered. However, when the preference activity is created I'd like to set the Summary fields to be the values in the corresponding preferences.
Please advise. Thanks.

public class MyPreferenceActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
sp.registerOnSharedPreferenceChangeListener(this);
} public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference pref = findPreference(key); if (pref instanceof EditTextPreference) { EditTextPreference etp = (EditTextPreference) pref; pref.setSummary(etp.getText());
} } }

Android :: Setting UI Preference Summary field to Value


Android :: Show Extra Info For Preference Screens When CheckboxPreference Summary Field Is Not Enough Long?

Mar 9, 2010

I have a screen where you can enable/disable modules for my Android application.

For this I use a CheckboxPreference screen. This is all good, but the summary field gets cut off if longer descriptions are added than 2 lines.

Suppose I have 4-5 lines of description available for each module, I would like to display this in a helper window.

I tried to bind a click event to the CheckboxPreference, but that fires for the whole line, so not only when the checkbox is clicked, and more, wherever you click on the line the checkbox is toggled.

So now I am wondering if this can be fixed. So if the user needs more info, just taps the text and the helper opens up, and if want to toggle the settings it taps the checkbox.

View 2 Replies View Related

Android :: Want More Text In Preference Summary / Get That?

Aug 9, 2009

It seems Preference summary text has a limit of about 2 lines, but I want more. How can I do that?

View 3 Replies View Related

Android :: How To Display Current Value Of Preference In Summary?

Feb 10, 2009

This must come up very often. When the user is editing preferences in an Android app, I'd like them to be able to see the currently set value of the preference in the Preference summary.

Example: if I have a Preference setting for "Discard old messages" that specifies the number of days after which messages need to be cleaned up. In the PreferenceActivity I'd like the user to see:
"Discard old messages" <- title
"Clean up messages after x days" <- summary where x is the current Preference value

Extra credit: make this reusable, so I can easily apply it to all my preferences regardless of their type (so that it work with EditTextPreference, ListPreference etc. with minimal amount of coding).

View 6 Replies View Related

Android :: How To Change SMS Preference / Setting?

Jul 14, 2010

In my application i m trying to change default android SMS Setting through programming. But i haven't find any document to how to change Messages Setting in android. I have seen package android.provider.Settings but in this package i haven't find any setting regarding SMS.

View 2 Replies View Related

Android :: Add Application Preference In Device Setting Opinion / API I Need To Use For That - Keyword?

Apr 26, 2010

How can I add application preference in device setting. I want to my preference setting be part of device setting opinion. My application setting can be appeared or displayed in device setting list.

Any API i need to use or keyword?

View 2 Replies View Related

Android :: After Changing A Preference - A Setting - Text Showing Settings Doesn't Update

Apr 13, 2010

I will try to explain a simple app scenario: My app goes right to a 'main view'. In this main view I have inserted a 'TextView' which displays current settings created by way of the PreferenceManager. For simplicities sake, let's say I have a checkbox in my settings. When I first start my app - the TextView on my main view shows my checkbox setting correctly (true). Now I go to the settings menu, it pops-up, and then I change it to false. I go back to the main view and...no change. It still say's true even after I changed it to false. If I end the app and then re-start it - all is well and it shows my change.

Apparently the main view just stays in the background while I'm changing settings? How can I redraw or update the main view after I change settings?

View 2 Replies View Related

Android :: Android - Avoiding Conflict Of Setting Text Field Values

Nov 17, 2010

I'm writing an Android application that allows a user to maintain a list of products. In the EnterProductData activity, the user can enter information about the product into form fields, which will then save the info to a SQLite DB. The EnterProductData activity also allows the user to initiate a barcode scan via the Barcode Scanner app in order to capture the UPC code. The problem I'm facing is trying to set the value of the UPC text field in onActivityResult() once the barcode scan activity is complete and returns the value.

What is ending up happening is my onResume() method is calling a function (populateFields()) that sets the values of the text fields to whatever is currently saved in the DB. And this seems to be happening after onActivityResult() is called. This means the scanned UPC is set as the text field value, only for an empty value to be set to it immediately after. The line of code to blame is commented with asterisks next to it. I imagine that if I immediately save the scanned UPC to the DB in the onActivityResult() method, I can avoid this problem, but that doesn't seem to be the best practice, in my opinion. Can someone advise me on what I should do?

EnterProductData.java
public class EnterProductData extends Activity {
private Button mScanButton;
private EditText mUPC;
private Button mSaveButton;
private Long mRowId;
private DbAdapter mDbHelper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
setContentView(R.layout.enter_product_data);
mUPC = (EditText) findViewById(R.id.UPC);
mScanButton = (Button) findViewById(R.id.scanButton);
mSaveButton = (Button) findViewById(R.id.saveButton);

mRowId = (savedInstanceState == null) ? null :
(Long) savedInstanceState.getSerializable(DbAdapter.KEY_PRODUCT_ROWID);
if (mRowId == null) {
Bundle extras = getIntent().getExtras();
mRowId = extras != null ? extras.getLong(DbAdapter.KEY_PRODUCT_ROWID): null;}
populateFields();
mScanButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
IntentIntegrator.initiateScan(EnterProductData.this);}});
mSaveButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
setResult(RESULT_OK);
finish();}});
}private void populateFields() {
if (mRowId != null) {
Cursor product = mDbHelper.fetchProduct(mRowId);
startManagingCursor(product);
mUPC.setText(product.getString(
product.getColumnIndexOrThrow(DbAdapter.KEY_UPC))); //******}
}@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
saveState();
outState.putSerializable(DbAdapter.KEY_PRODUCT_ROWID, mRowId);
}@Override
protected void onPause() {
super.onPause();
saveState();
}@Override
protected void onResume() {
super.onResume();
populateFields();
}private void saveState() {String upc= mUPC.getText().toString();
if (mRowId == null) {
long id = mDbHelper.createProduct(mRowId, UPC);
if (id > 0) mRowId = id;
}} else {mDbHelper.updateProduct(mRowId, UPC);
}}protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case IntentIntegrator.REQUEST_CODE: {
if (resultCode != RESULT_CANCELED) {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (scanResult != null) {
String upc = scanResult.getContents();
mUPC.setText(upc);
}}break;
}}}}

View 1 Replies View Related

Android :: How I Can Find Call Timer Or Summary?

Jun 8, 2010

i want to know how i can find call timer or summary in my htc desire phone?

View 3 Replies View Related

Android :: Stock API List - Market Index Summary

Apr 28, 2010

I am making application in android just like the google finance. My first step is to show the market index summary, I have search the api list. But I could not get any api related to it. I do not want to use any java script. I need basically links this example if I put the symbol as GOOG it should display the information like this.
529.06 -2.58 (-0.49%) After Hours: 529.20 +0.14 (0.03%) Apr 27, 6:47PM EDT NASDAQ real-time data - Disclaimer

1. Range 527.23 - 538.33
2. 52 week 381.54 - 629.51
3. Open 528.94
4. Vol / Avg. 3.84M/3.64M
5. Mkt cap 168.46B
6. P/E 23.97
7. Div/yield
8. EPS 22.07
9. Shares 318.41M
10. Beta 1.11
and chart for this particular symbol.

View 3 Replies View Related

HTC Desire :: App For Call Duration Summary?

May 15, 2010

is there an app available that shows call duration on screen once you disconnect, or is it a setting somewhere within the phone that I have just missed...?

View 4 Replies View Related

Samsung Moment :: List / Summary Of Application Sizes

Apr 8, 2010

Where can I find a list of how much space my apps are taking up? I'd like to see how much more memory I have on my phone and on my SD card. Do the apps store on the phone or the memory card?

View 1 Replies View Related

General :: Lenovo A60 - How To Stop Post Call Summary

Jul 24, 2012

I have a Lenovo a60 and been using this phone for several months. I have subcribed a unlimited data plan for 6 months and i dont need to see how much data the phone is used up or how much time i talked on my phone.... in short i don't want to see the post call summary. I remember Nokia have a switch to put this OFF but there is no such thing in Android 2.3. Any way to stop this annoying display of summary

View 1 Replies View Related

Motorola Droid :: Summary Of E-mail And Calendar Events On Unlock Screen?

Feb 5, 2010

Is there a way to see summary of e-mail and calendar events on the unlock screen? Would be nice to see my next appointment on the screen instead of unlocking and having a look.

I searched but didn't find anything.

View 10 Replies View Related

Android :: First Run Preference Initialization

Feb 15, 2010

I have next situation: After installing application it has to init settings from server. And while it is not has right preferences it has to wait. I have several receivers and service - I don't want to check for initialization in every action in these components - I think there have to be better solution.

View 3 Replies View Related

Android :: How To Get Specific Preference And Set Its Value?

Sep 23, 2010

I have the following code in my application in res/xml/preferences.xml:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Wi-Fi settings">
<EditTextPreference
android:key="pref_voice_threshold_top"
android:title="@string/title_pref_voicetopthreshold"
android:dialogTitle="@string/dialog_title_pref_voicetopthreshold"
android:defaultValue="20" android:inputType="number"/>
</PreferenceCategory> </PreferenceScreen>

And I was wondering is it possible for me to then use this preference in code so I can update it via downloading an xml file? So I currently display the above preference in a PreferenceActivity, which works fine, however I want to be able to update the setting by downloading a new setting every week from the internet. So my question is how do I open this preference in code and set its value to the new downloaded value?

View 2 Replies View Related

Android :: How To Set Preference In Code?

Feb 16, 2009

I have an Android application in which I have my preferences in a xml file, which works fine. I've now want to set one of the preferences using code instead of displaying the entire preference screen, how would I go about doing this?

View 1 Replies View Related

Android :: Mangled Preference Activity

Sep 24, 2009

I have pretty unassuming preferences screen based on Preference Activity. (You can see it in DroidIn app) I'm having some problems with it that I think have to do with redrawing the screen after updates. Here are the symptoms: 1. OnPreferenceChangeListener#onPreferenceChange if I change summary of the preference by doing Preference#setSummary the new value is painted over the old one creating unsightly effect 2. My preferences screen is large enough that user has to scroll. While scrolling, the whole screen get all messed up, again it looks like view is redrawn (when scrolled) without erasing the background first.

View 2 Replies View Related

Android :: How Do You Create Custom Preference?

Aug 12, 2010

PreferenceManager contains very useful methods like "registerOnActivityResultListener" which enables you to call startActivityForResult in your custom preference like RingtonePreference does but it's restricted at the package level.So tell me, let's say I wanted a ImagePreference. How should I proceed? I want to be able to use a activity for result intent with the PICK action.

View 7 Replies View Related

Android :: ListPreference In Preference View

Jan 17, 2010

This is my first Android app (which is a soft keyboard, with dvorak layout) and so far it has gone pretty smoothly (either because or despite working from the sample code). I've had some problems (with special/swedish characters) that I've managed to take care of, but this problem I can't figure out how to solve..

But when I click the list item to edit it, i get an empty dialog (Title and button is shown right and with the text I set in the xml- file, but no list, screenshot: http://i49.tinypic.com/2501p55.png ). I can't see any problem with the program code (which isn't many lines..) or the xml (the arrays are generated by the Android utils in Eclipse and the preferences is a mix of auto and manual). You can see both Java code and XML here: http://pastebin.com/m4c52c3a2 (titles etc in Swedish..) (I've also tried a EditTextPreference item, which seemed to work fine..) I have also looked at the log/output using adb, and can't see any problems there either, so I have no idea onto how to solve this.

View 2 Replies View Related

Android :: Where To Store Preference Keys?

May 18, 2010

When I create preference activity I define all preferences in xml file. Every preference has a key defined in this xml. But when I access preference I write:

SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean foo_value = appPreferences.getBoolean("foo_key_defined_in_xml", false);

Is there any way to avoid referencing "foo_key_defined_in_xml" in hard-coded way? Maybe there is a possibility to reference it in R style way (not to refer to string)?

View 4 Replies View Related

Android :: Default Value Of Preference Defined In XML

May 4, 2010

How do you get the default value of an Android preference defined in XML?
Context: I don't want to repeat the definition of the default value in both the code and the preferences XML.

View 1 Replies View Related

Android :: Preference Name Have To Be Unique For Every Application?

May 17, 2010

For my private static final String PREFS_NAME = "mypref"; does the PREFS_NAME have to be unique for every application? Or can I use the same one over and over.

View 1 Replies View Related

Android :: How To Declare Type Of Preference?

Mar 16, 2010

I have a preferences.xml that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference android:name="Sample" android:enabled="true"
android:persistent="true" android:summary="Sample" android:defaultValue="3.0"
android:title="Sample" android:key="sample" /> </PreferenceScreen>

When I do sp.getString("sample", "3.0"), it works fine and returns a string, but it shouldn't be a string, it should be a float. Running sp.getFloat("sample", 3.0f) throws a ClassCastException because it is a string. What should I put in the XML so that the preference is stored as a float?

View 3 Replies View Related

Android :: Emulate Preference Category Look

Jul 28, 2010

I like title bar style in android preference category. In my activity (no preferenceactivity) I want to use same style, how I can do?

View 1 Replies View Related

Android :: How To Get Pressed State Of Preference

Sep 10, 2009

There is know problem in all the Android phones. Go to Bluetooth Settings->Turn ON bluetooth->Click on bluetooth discovery->Then timer will start in summary->Long press on Bluetooth device discovery-> observe Bluetooth ON/OFF title start to toggle with Bluetooth Discovery toggle. I analyzed the issue. Blueooth ON/OFF is CheckBoxPreference. Bluetooth Discovery is also CheckBoxPreference which has dependency on Bluetooth ON/OFF. When we click on Bluetooth discovery then On thread will run at every second to update summary in Bluetooth Discovery preference. When we change the Bluetooth discovery to OFF then thread will be removed/ killed. When i press the Bluetooth discovery for long time when its already in ON State then still the thread will be updating the summary (remaining time from 120 to 00) till i press it. When i leave the Thread will stop. As it has dependency on Bluetooth ON/OFF, its making to the title invisible. But it should not happen. Solution: When i touch the Device Discovery i should kill the update summary thread then i guess, that problem will be solved. But in prefence i dont have any listener to know the pressed state. I hope somebody can give me solution.

View 2 Replies View Related

Android :: GPS Lookup And User Preference

Aug 6, 2010

I'm starting to dip my toes into LocationManager. I've created a service which tracks GPS location (interval is more than 60000ms) and updates my application with user location so they can find stuff nearby. As I understand it, users can go into their preferences and disable GPS for a particular application. I would essentially like to offer my users two modes.
1) GPS. 2) If GPS can not pull, device does not have a GPS chip, or GPS is turned off for my app, I would like to allow them to type in their zip code (or maybe switch to cell tower lookup).

The bold text is what I'm interested in. How can I tell if the device does not have GPS? How can I tell if the user has disabled GPS for my application?
Side question: My service gets launched from my 2nd Activity. I call stopService in the onDestroy method of this Activity. If I back up to my 1st Activity and the 2nd Activity is destroyed, I still notice the GPS icon on my phone running. Is stopping the service sufficient? Or do I need to stop the LocationManager in the onDestroy of the service?

View 2 Replies View Related

Android :: Intent Receiver According To Preference

Apr 9, 2010

I have a intent receiver in my android manifest, but would like to give the user the opportunity to choose whether he/her wants the app to automatically start at the specific state. Until now, I've used a service with a broadcast receiver, but I really want to delete this service as it seems a bit unnecessary.

Can register the intent action only if the user wants it (I guess not)? If not, should I make a class that will be called every time the intent is received and checks the user's preference or should I keep the service?

View 1 Replies View Related

Android :: Modify Checkbox Preference ?

Mar 27, 2010

If I can modify the checkbox preference in order to inverse the direction from left to right to right to left.

View 2 Replies View Related

Android :: Share Preference Across Several Activities?

Feb 14, 2009

I have two activities in two different packages: com.foo.a and com.foo.b. Is it possible to create an PreferenceActivity (with the exact same XML file) so that the preference is shared across the two activies?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved