카드보기 안에 파이 차트를 만들려고합니다. fro 차트를 만드는 중 achartEngine-1.1을 사용 중입니다. 나는 카드보기 bcz를 사용하고 있습니다. 나는 목록보기에서 차트의 번호를 원합니다. 차트의 제목에 선형 레이아웃과 텍스트보기가있는 XML 파일 이름 dashboard_graph_view를 디자인했습니다. 내부에 원형 차트를 배치하는 상대 레이아웃을 만들었습니다.하지만 코드를 실행하면 원형 차트가 만들어지지 않았습니다. 그러나 텍스트보기를 만들 때 텍스트가 보이기 시작했습니다. 나는 구글을 시도했지만 유용한 것을 발견하지 못했습니다. 다음은 getview의 코드입니다.카드보기 안의 파이 차트가 안드로이드에 보이지 않습니다.
public View getView(int arg0, View v, ViewGroup arg2) {
// TODO Auto-generated method stub
if(v==null)
v = inflater.inflate(R.layout.dashboard_graph_view, null);
TextView txt1 = (TextView) v.findViewById(R.id.tittle);
txt1.setText(port_list.get(arg0).get("portlet_title"));
// Pie Chart Section Names
String[] code = new String[] {
"Eclair & Older", "Froyo", "Gingerbread", "Honeycomb",
"IceCream Sandwich", "Jelly Bean"
};
// Pie Chart Section Value
double[] distribution = { 3.9, 12.9, 55.8, 1.9, 23.7, 1.8 } ;
// Color of each Pie Chart Sections
int[] colors = { Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN, Color.RED,
Color.YELLOW };
// Instantiating CategorySeries to plot Pie Chart
CategorySeries distributionSeries = new CategorySeries(" Android version distribution as on October 1, 2012");
for(int i=0 ;i < distribution.length;i++){
// Adding a slice with its values and name to the Pie Chart
distributionSeries.add(code[i], distribution[i]);
}
// Instantiating a renderer for the Pie Chart
DefaultRenderer defaultRenderer = new DefaultRenderer();
for(int i = 0 ;i<distribution.length;i++){
SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();
seriesRenderer.setColor(colors[i]);
seriesRenderer.setDisplayChartValues(true);
// Adding a renderer for a slice
defaultRenderer.addSeriesRenderer(seriesRenderer);
}
defaultRenderer.setChartTitle("Android version distribution as on October 1, 2012 ");
defaultRenderer.setChartTitleTextSize(20);
defaultRenderer.setZoomButtonsVisible(true);
GraphicalView graph_view = ChartFactory.getPieChartView(app.getApplicationContext(), distributionSeries, defaultRenderer);
// Creating an intent to plot bar chart using dataset and multipleRenderer
// Bundle intent = ChartFactory.getPieChartIntent(app.getBaseContext(), distributionSeries , defaultRenderer, "AChartEnginePieChartDemo");
RelativeLayout l1 = (RelativeLayout) v.findViewById(R.id.graph_view);
l1.addView(graph_view,new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// Start Activity
graph_view.repaint();
l1.refreshDrawableState();
return v;
}
여기에 xml 파일이 있습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/feed_bg"
android:layout_marginBottom="-9dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="@dimen/feed_item_margin"
android:layout_marginRight="@dimen/feed_item_margin"
android:layout_marginTop="@dimen/feed_item_margin"
android:background="@drawable/bg_parent_rounded_corner"
android:orientation="vertical"
android:paddingBottom="@dimen/feed_item_padding_top_bottom"
android:paddingTop="@dimen/feed_item_padding_top_bottom" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/feed_item_padding_left_right"
android:paddingRight="@dimen/feed_item_padding_left_right" >
<TextView
android:id="@+id/tittle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:textSize="@dimen/feed_item_profile_name"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="@+id/graph_view"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.91"
android:orientation="horizontal"
android:paddingLeft="@dimen/feed_item_padding_left_right"
android:paddingRight="@dimen/feed_item_padding_left_right" >
</RelativeLayout>
</LinearLayout>
</LinearLayout>
미리 감사드립니다.
고맙습니다. –
안녕하세요 두 가지 차트를 번갈아 삽입하려고하면 동일한 문제가 있음을 알고 있습니다. 원형 차트와 Barchart를 스크롤 한 후 카드 목록에 단어를 올리면 모든 막대 차트가 원형 차트로 변환되어 문제를 찾을 수 있습니다. .... @ Bruce –