Android: how to create lists under the charts in Achartengine?

孤街醉人 提交于 2019-12-11 03:36:34

问题


Android: Hi, I'm using AchartEngine to display charts in my App
I have tried different ways to display this charts with some lists under the chart in my app, but I haven't. I have no Idea about how to use these charts with defining layouts in xml. I'm able to display the graphs without using the xml layouts.

Many Thanks in Advance.

Regards, Harry.


回答1:


If Achartengine is referenced in your project (or compiled if you are including the source) then you should see the view available in the eclipse layout designer.

Just drag the view onto your layout.

Alternatively you can dynamically create your layout however this will require a little extra work and research




回答2:


AchartEngine has a class ChartFactory which is used for creating views or intents.

So, possibly you can set the view returned at desired place in the xml.

This way you can create a xml, here I have a LinearLayout that will contain my Graph.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ListView android:id="@+id/list_view" android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <LinearLayout android:id="@+id/myLinearLayout"
        android:layout_width="wrap_content" android:layout_height="wrap_content">
    </LinearLayout>
</LinearLayout>

Now, in Activity class you can show the Graph by getting the id of LinearLayout and adding view to your LinearLayout. In the onItemClick() of the ListView show the Graph.

    XYMultipleSeriesRenderer renderer = Bar_Chart.getBarDemoRenderer();
    linear_layout.removeAllViews();
    View mView = ChartFactory.getBarChartView(this, Bar_Chart.getBarDemoDataset(), renderer, Type.DEFAULT);
    mView.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) );
    linear_layout.addView(mView);


来源:https://stackoverflow.com/questions/7739469/android-how-to-create-lists-under-the-charts-in-achartengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!