The Context
is available in an Activity
starting with the onCreate()
method. If you initialize the GraphView
as a field your code will fail as the Context
is not available yet(you should never initialize Views
as you do with the GraphView
). So instead of:
GraphView Grafico = new LineGraphView(this, "GraphTest");
do this:
GraphView Grafico;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Grafico = new LineGraphView(this, "GraphTest");
}
Also, you should add the library by either using the GraphView
project directly or by using the jar directly in the libs
folder(see this answer).