The problem I am having is getting a listview to work inside my fragment. I have tried creating a custom adapter but then I don't have anything appear on my screen, perhaps I am not doing it right.
My main xml for fragment looks like this:
<ListView
android:id="@+id/pieChartView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
/>
The adapter layout looks like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="2dp"
/>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart2"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="2dp"
/>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart3"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="2dp"
/>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart4"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="2dp"
/>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart5"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="2dp"
/>
The fragment code :
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_piechart, container, false);
Log.i(ACTIVITY_NAME, "In onCreate()");
chart1 = root.findViewById(R.id.chart1);
chart2 = root.findViewById(R.id.chart2);
chart3 = root.findViewById(R.id.chart3);
chart4 = root.findViewById(R.id.chart4);
chart5 = root.findViewById(R.id.chart5);
ChartOne();
ChartTwo();
return root;
}
The problem I am having is creating a custom adapter inside the fragment. I tried one and then with my code above I got an error with where I create the charts(ChartOne,ChartTwo).