Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4619652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:27:12+00:00 2026-05-22T02:27:12+00:00

I am tryig to write an Android Honeycomb application and I am having trouble

  • 0

I am tryig to write an Android Honeycomb application and I am having trouble subclassing Preference: http://developer.android.com/reference/android/preference/Preference.html

I want to make a similar layout with title and summary but also a progress bar.

I have created the layout and added the custom preference class but I can’t seem to get hold of the instance of it to set the values of the items in it.

It seems that the preference key doesn’t work for the custom class.

Here is my preference definition compared to the standard preference class:

               <Preference
                android:key="int_free_storage"
                android:title="Free Space"
                android:summary="free storage value here"/>

            <com.hamid.storageether.SpacePreference
                android:key="int_space_test"
                android:title="Test"
                android:summary="This is my custom preference"/>

My my preference subclass then sets my XML layout as it’s layout resource in its constructor

setLayoutResource(R.layout.space_pref_layout);

it also overrides the setTitle and setSummary methods….

In my main PreferenceActivity I try to get hold of my Preference by it’s key but no luck it seems, since the preference never gets updated:

// These Two work
Preference intTotal = (Preference)findPreference("int_total_storage");
Preference intFree = (Preference)findPreference("int_free_storage");
           intTotal.setSummary("Standard Preference Summary 1");
           intFree.setSummary("Standard Preference Summary 2");

// My subclass doesn't - It just displays the default text defined in the layout xml.
SpacePreference intTest = (SpacePreference)findPreference("int_test_space");
            intTest.setTitle("Testtttyyy");
            intTest.setSummary("Test Summary");

Could someone please point me towards where I may be going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:27:13+00:00Added an answer on May 22, 2026 at 2:27 am

    Is this code copied straight from the program or retyped? If copied, then your key is “int_space_test” in XML and “int_test_space” in code. It should be throwing a null pointer exception on the next line where you use intTest if that’s the case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write an android tablet application which scans for a set
I am trying to write an android application and my workflow is as follows:
I am trying to write a very simple Android application that checks the signal
so I'm trying to write a small piece of android code where I want
I am trying to write an application for Android that functions as a service
I am trying to write a simple proxy application on Android in Java to
I am a new android developer trying to write a simple contact book. When
I am trying to write a simple Android application using the NDK and C++.
I'm trying to write application for Android to access Google Tasks. I decided to
I am trying to write a simple android application to help interpret some lab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.