halfhp / androidplot

Charts and plots for Android
http://androidplot.com
Apache License 2.0
505 stars 159 forks source link

QuickStart App error #87

Closed RobLewis closed 5 years ago

RobLewis commented 5 years ago

I'm trying to adapt the example to my app but so far I'm getting this error: Error inflating XML (class com.androidplot.xy.XYPlot): Setter requires param of unsupported type: class com.androidplot.ui.widget.TextLabelWidget which apparently is a problem with the setContentView( R.layout.activity_graph ); statement in my onCreate() method. I've created the line_point_formatter_with_labels.xml resource as described in QuickStart, but can't find any documentation addressing my problem.

RobLewis commented 5 years ago

More information: In my layout XML file, I get an error "unknown attribute" for every parameter I try to enter with Fig syntax, specifically:

        androidPlot.title="Temp History"
        androidPlot.domainTitle="min"
        androidPlot.lineLabelRotationBottom="-45"
        androidPlot.lineLabels="left|bottom"
        androidPlot.rangeTitle="°F"

I tried adding the Fig dependency, but Gradle tells me it is unable to resolve it. If I change to the other syntax, for example ap:title="Temp History" Android Studio colors the "ap" red and tells me "Namespace 'ap' is not bound".

I'm at a loss.

halfhp commented 5 years ago

Hi Rob,

I tried adding the Fig dependency, but Gradle tells me it is unable to resolve it.

Fig is included as part of the Androidplot core library so there's no need to include it yourself.

Android Studio colors the "ap" red and tells me "Namespace 'ap' is not bound".

Make sure you're binding the ap namespace in your layout using xmlns:ap="http://schemas.android.com/apk/res-auto" as shown in the Quickstart.

My advice to start would be to forget about using Fig in your layout for now and remove any line that starts with androidPlot and replace it with it's ap: namespace equivalent (all of the androidPlot.xxx properties you're using above are instructing fig to try to reflectively configure properties that dont actually exist. You can read a little more about that in the Fig lib documentation if you're interested, but it's not really necessary to solve your problem.)

If you're still running into trouble, feel free to ask followup questions on Stack Overflow using the androidplot tag.

RobLewis commented 5 years ago

Thanks. The problem was the missing xmlns:ap. Don't know how I missed that because I specifically looked for such things. One problem was my ignorance: I'd always seen these statements in the root element of a layout and didn't know it was OK to put them in children. Mine is in the root ConstraintLayout and seems to work there. Any reason to move it?