Home > Back-end >  The novice fragments problems? Hope the great god save! Thank you very much!
The novice fragments problems? Hope the great god save! Thank you very much!

Time:10-27

fragments looks something like this: [color=# 0000 ff]
[/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 the
For 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
  • Related