[/color]
Public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
The View v=inflater. Inflate (R.l ayout. Ac_frament3, container, false);
InitView ();
Return v.
}
Private void initView () {
PieChart=(pieChart) getActivity (). The findViewById (R.i d.p ie_chat1);
ShowhodlePieChart ();
}
Private void showhodlePieChart () {
Omit...
PieChartManagger PieChartManagger=new PieChartManagger (pieChart);
PieChartManagger. ShowSolidPieChart (yvals, colors);
}
pieChartManagger class looks something like this:
Public class PieChartManagger {
Public PieChart PieChart;
Public PieChartManagger (PieChart PieChart) {
Enclosing pieChart=pieChart;
InitPieChart ();
}
//initialize
Private void initPieChart () {
PieChart. SetDrawHoleEnabled (false); the location of the error
Omitted,,,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Error code:
Java. Lang. NullPointerException: Attempt to invoke virtual method 'void com. Making. Mikephil. Charting. Charts. The PieChart. SetDrawHoleEnabled (Boolean)' on a null object reference
CodePudding user response:
Then I tried a few times in, I found error is set when theFor example:
BarChart. SetDescription (null);
BarChart. SetDrawBarShadow (false);
BarChart. SetDrawBarShadow (true);
The
Are all on a null object reference error
I don't know how to return a responsibility
CodePudding user response:
Because your pieChart object is empty so when setting this attribute will throw an exception, you have a look at this line PieChartManagger PieChartManagger=new PieChartManagger (pieChart); Code your pieChart object assignment is successful, you directly transfer pieChart as method parameters will be more convenient