AchartEngine has a ChartFactory class that is used to create views or intentions.
So, perhaps you can set the view returned to the right place in xml.
So you can create 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 the Activity class, you can display the graph by receiving the LinearLayout identifier and adding it to LinearLayout. The onItemClick() the ListView list shows a 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);
source share