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

by » 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
    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
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
android/launcher/ 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: ;a=blob;f=core/java/android/widget/;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.



Sponsored Links

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

by » Thu, 12 Mar 2009 09:41:39 GMT

 thanks Jon Colverson.
I can see also that mInLayout isn't actually protected, it has
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


|| 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
2. cloudList, Click here
3. Midomi, Click here
4. NewsRob, Click here
5. Mobile, Click here
I shared these apps through appSharers,which is a platform for people to
share cool apps with friends.Install it by click 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

To request to subscribe to this group:


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