在android中绘制图形

时间:2013-10-05 00:24:48

标签: java android graph

我是android开发的新手。我需要绘制一个动态图形,其中值必须存储在sqlite数据库中。我正在使用jjoe64 graphview库来绘制它...现在的问题是如何将字符串作为值插入图形。我已经尝试过并寻找解决方案,但仍找不到完美的解决方案......

代码如下: -

import com.jjoe64.graphview.BarGraphView;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.GraphView.GraphViewData;
import com.jjoe64.graphview.GraphViewSeries;
import com.jjoe64.graphview.LineGraphView;

import dev.starmobile.database.MarkAdapter;
import dev.starmobile.database.MarkOpenHelper;

import android.os.Bundle;
import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.widget.LinearLayout;

    public class GraphActivity extends Activity {
    MarkAdapter adapter;
    MarkOpenHelper helper;
    SQLiteDatabase db;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_graph);
        adapter = new MarkAdapter(this);

        double sem = Double.parseDouble(helper.SEMESTER);
        double mark = Double.parseDouble(helper.MARK);

        GraphViewSeries markValue = new GraphViewSeries(
                new GraphViewData[] {sem,mark });

        GraphView myGraphView = new LineGraphView(this // context
                , "Performance" // heading
        );

        myGraphView.addSeries(markValue); // data

        LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
        layout.addView(myGraphView);

    }

数据库中的声明

// public static final String SEMESTER = "STUD_SEM";
// public static final String MARK = "STUD_MARK";

0 个答案:

没有答案