access parent's protected variable when extend a android class!

by jusun...@gmail.com » Tue, 10 Mar 2009 16:48:43 GMT


Sponsored Links
 I liked to extend a Gallery widget class, so I tried to extend and
I faced the problem of using protected variable.

this is a Gallery source
@Override
    protected void onLayout(boolean changed, int l, int t, int r, int
b) {
        super.onLayout(changed, l, t, r, b);
          /*
         * Remember that we are in layout to prevent more layout
request from
         * being generated. [android comment]
         */
        mInLayout = true;
        layout(0, false);
        mInLayout = false;
    }
and I changed
@Override
protected void onLayout (boolean changed, int l, int t, int r, int b)
{
    super.onLayout (changed, l, t, r, b);
    mInLayout = true;
    MyLayout (0, false);
    minLayout = false;
}

I build.. and result is
/home/bobos26/work/devel/omap_test/packages/apps/Launcher/src/com/
android/launcher/WRGallery.java:27: mInLayout is not public in
android.widget.AdapterView; cannot be accessed from outside package
        mInLayout = true;
        ^
the result log mean that I can't accessed the protected variable
mInLayout from outside package. I think I can access a parent's
protected variable when extending class in Object oriented
programming theory. am I wrong? and is there a good solution to access
a parent's protected variable?

--~--~---------~--~----~------------~-------~--~----~



access parent's protected variable when extend a android class!

by Jon Colverson » Tue, 10 Mar 2009 23:22:24 GMT


 


You're correct that a subclass can access its parent's protected
variables, but if you look at the AdapterView source:
 http://android.git.kernel.org/?p=platform/frameworks/base.git ;a=blob;f=core/java/android/widget/AdapterView.java;h=173e80f54f75ee3051ac8e774ce18b4c9338eea8;hb=HEAD

you can see that mInLayout isn't actually protected, it has default
(package) visibility. I'm not sure what the solution is for your
particular problem.

--
Jon

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


access parent's protected variable when extend a android class!

by jusun...@gmail.com » Thu, 12 Mar 2009 09:41:39 GMT


 thanks Jon Colverson.
I can see also that mInLayout isn't actually protected, it has
default.
then.....
but when I build, build log tell me that I cannot access mInLayout
from outside package
please. help me!! nobody know the reason?


--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Viewing logs on native android

Hi All,
         As we see emulator's logs in logcat of eclipse. What is similar on
native android to view these logs ?

Thanks in advance

-- 
...Swapnil

|| Hare Krishna Hare Krishna Krishna Krishna Hare Hare ||
|| Hare Rama    Hare Rama   Rama   Rama    Hare Hare ||

-- 

2. These are my favorite android apps.

Hi all, gw lagi ngetest apps nih.. namanya appShare.. fungsinya buat
nge-share aplikasi yg kita suka trus ngirim ke email..

Sayangnya aplikasi yg kita share tsb cuma sbg link doang, buat downloadnya
ttp harus dr market.. :(

Nevertheless it'sa pretty cool app.. dibawah ini contoh emailnya.. :)

Hi, I find some interesting apps :

1. appSharers, Click here
http://market.android.com/search?q=pname:com.eoemobile.apps.eSharer
2. cloudList, Click here
http://market.android.com/search?q=pname:com.quarterstaf.cloudlist
3. Midomi, Click here
http://market.android.com/search?q=pname:com.melodis.midomiMusicIdentifier
4. NewsRob, Click here http://market.android.com/search?q=pname:com.newsrob
5. Photoshop.com Mobile, Click here
http://market.android.com/search?q=pname:com.adobe.psmobile
***************************
I shared these apps through appSharers,which is a platform for people to
share cool apps with friends.Install it by click
http://market.android.com/search?q=pname:com.eoemobile.apps.eSharer in your
Gphone and try to share some cool apps with me :)

*Note:This URL can only be used in your Gphone.

--
sent from my Android

--~--~---------~--~----~------------~-------~--~----~
=========================
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:

Click  

3. I'm looking for objective of my master thesi

4. using pcaket video codecs in commercial projects, not android based

5. Adding hidden extra data to a ListView item

6. Unable to determine signal strength on Droid / Android 2.0 (onSignalStrengthsChanged deprecated)

7. AutoCompleteTextView, passing the focus and Android 1.6