Programmatically creating scrollview(s) from custom component in android
Posted
by jaapbeetstra
on Stack Overflow
See other posts from Stack Overflow
or by jaapbeetstra
Published on 2010-05-21T13:16:00Z
Indexed on
2010/05/21
13:20 UTC
Read the original article
Hit count: 1525
I'm trying to build a compound control in Android, containing (among other things) a ScrollView. Things go wrong when I try to view the control in Eclipse, crashing with a NullPointerException after the error message: "Parser is not a BridgeXmlBlockParser".
Stacktrace:
java.lang.NullPointerException
at android.view.View.<init>(View.java:1720)
at android.view.ViewGroup.<init>(ViewGroup.java:277)
at android.widget.FrameLayout.<init>(FrameLayout.java:83)
at android.widget.ScrollView.<init>(ScrollView.java:128)
at android.widget.ScrollView.<init>(ScrollView.java:124)
at android.widget.ScrollView.<init>(ScrollView.java:120)
at my.compound.control.StringPicker.onMeasure(StringPicker.java:46)
...
I've traced the error to the following conditions:
- The NPE is thrown because a
Context.obtainStyledAttributes()call returnsnullwhen theattrsargument passed isnull. - This only applies to the
BridgeContextimplementation used in Eclipse, which expectsattrsto be an instance of theBridgeXmlBlockParser. - The
attrsargument isnullbecause I create the ScrollView using the (Context) constructor.
There is a workaround of course, which is passing the attrs I receive when Eclipse constructs the compound control, but I don't want all the attributes set on the compound control to apply to my inner control.
Am I doing something wrong, is this a bug in Android Eclipse, ...?
© Stack Overflow or respective owner