I have this strange problem with my adapter due to which no methods are called. The constructor works, it stops there if I have a breakpoint, but there is nothing from there. onCreateViewHolder not called either onBindViewHolder or even getItemCount .. I tried everything I could find on the Internet, but nothing works, so I donβt know what to do. Any suggestions? Here is my code: Fragment:
public class FragmentPackageDetails extends Fragment { //other vars RecyclerView rvPackageDetails; DatabaseHandler database; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getArguments(); String temp = args.getString(KEY_TRACKER_CODE); View v = inflater.inflate(R.layout.fragment_package_details_new, container, false); return v; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); rvPackageDetails = (RecyclerView) view.findViewById(R.id.rvPackageDetails); rvPackageDetails.setLayoutManager(new LinearLayoutManager(getActivity())); database = new DatabaseHandler(getActivity()); selectedPackage = database.getPackage(trackerCode); RecyclerView.Adapter adapter = new MyAdapter(selectedPackage.getRecords()); rvPackageDetails.setAdapter(adapter); } //other methods in class }
Myadapter
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> { private ArrayList<TrackingRecordCheckedOut> mDataset;
Fragment Layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v7.widget.RecyclerView android:id="@+id/rvPackageDetails" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
RecyclerView line layout:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/llPackageDetailsRecyclerViewRow" android:layout_width="match_parent" android:layout_height="96dip" android:orientation="horizontal" android:weightSum="100"> <LinearLayout android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="20" android:orientation="vertical" android:weightSum="10"> <TextView android:id="@+id/tvPackageDetailsRowDayOfWeek" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="3"/> <TextView android:id="@+id/tvPackageDetailsRowDayOfMonth" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="4"/> <TextView android:id="@+id/tvPackageDetailsRowNameOfMonth" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="3"/> </LinearLayout> <LinearLayout android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="80" android:orientation="vertical"> <TextView android:id="@+id/tvPackageDetailsRowDetailsTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3"/> <TextView android:id="@+id/tvPackageDetailsRowDetailsDescription" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="4"/> <TextView android:id="@+id/tvPackageDetailsRowDetialsTime" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3"/> </LinearLayout> </LinearLayout>
java android adapter android-fragments android-recyclerview
csanonymus
source share