Guten Tag gegossen werden,android.support.v4.widget.NestedScrollView kann nicht auf android.support.v7.widget.RecyclerView
ich ein Fragment mit einem RecyclerView einschließlich den Elemente zu schaffen versuchen.
Über diesen Punkten muss ich eine Überschrift mit einigen Filtern setzen.
Hier ist das XML-fragment (fragment_products_list):
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12sp"
android:id="@+id/filters_frame">
<include layout="@layout/expandable_filters"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Hier ist die OnCreateView in meinem Fragment Java-Datei (ListFragment.java):
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
RecyclerView rv = (RecyclerView) inflater.inflate(
R.layout.fragment_products_list, container, false);
//Product filters
expandFiltersButton = (ImageButton) getView().findViewById(R.id.expand_filters);
expandableZone = (LinearLayout) getView().findViewById(R.id.expandable_zone);
expandFiltersButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(expandableZone.isShown()){
expandableZone.setVisibility(View.GONE);
expandFiltersButton.setImageResource(R.drawable.ic_more_24dp);
}else{
expandableZone.setVisibility(View.VISIBLE);
expandFiltersButton.setImageResource(R.drawable.ic_less_24dp);
}
}
});
setupRecyclerView(rv);
mRecyclerView = rv;
loadUpdates();
return rv;
}
ich diesen Fehler haben Code, wenn ich versuche, die App zu starten:
android.support.v4.widget.NestedScrollView cannot be cast to android.support.v7.widget.RecyclerView
Was ist das Problem und wie kann ich es lösen? Danke für Ihre Hilfe!
gefunden Sie die endgültige Lösung, vielen Dank! –
Froh, dass es geholfen hat !! –