0
我閱讀了關於使用(android)GraphView庫的介紹性信息,並且在使用演示應用程序(一切都已重建,它工作)時無法使其工作,但現在實現其方法在我的活動中不會。使用Android GraphView Library遇到的問題
import java.util.Date;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;
public class MainActivity extends Activity implements android.view.View.OnClickListener{
//create the column headers
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.graph_view);
// init example series data
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {
new GraphViewData(1, 2.0d)
, new GraphViewData(2, 1.5d)
, new GraphViewData(3, 2.5d)
, new GraphViewData(4, 1.0d)
});
GraphView graphView = new LineGraphView(
this // context
, "GraphViewDemo" // heading
);
graphView.addSeries(exampleSeries); // data
LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);
}
,這裏是我的xml文件:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="250dip"
android:id="@+id/graph1"
tools:context=".MainActivity" />
我剛剛檢查了從一個圖形引擎提供的代碼,文檔和社區提供了啓動和運行所需的信息。謝謝, – 7888