Question

Je suis en train de travailler sur une Application dès maintenant qui utilise 3 onglets avec un fragment de chacun et je suis en train de mettre en œuvre SwipeRefreshLayout dans chacun de ces fragments.Je crois que j'ai créé ce correctement, mais j'obtiens toujours l'erreur:

android.view.InflateException: Binary XML file line #1: Error inflating class SwipeRefreshLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.SwipeRefreshLayout" on path: DexPathList[[zip file "/data/app/com.ryan.brooks.fropllc.frop.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.ryan.brooks.fropllc.frop.app-1, /vendor/lib, /system/lib]]
    at com.ryan.brooks.fropllc.frop.app.whatsGoingOnFragment.onCreateView(whatsGoingOnFragment.java:23)

Maintenant, je n'ai absolument aucune idée de ce qui est à l'origine.Si quelqu'un pouvait m'aider ce serait énormément apprécié.

Voici mon fragment de la disposition où je me suis mise en œuvre de la SwipeRefreshLayout:

<SwipeRefreshLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/swipe_refresh_whats_going_on">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#343434"></ScrollView>

</SwipeRefreshLayout>

Et voici mon fragment de la classe où je suis l'appel de la SwipeRefreshLayout.

public class WhatsGoingOnFragment extends Fragment {

    private SwipeRefreshLayout swipeLayout;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.whats_going_on_fragment, container, false);

        // Retrieve the SwipeRefreshLayout and ListView instances
        swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_whats_going_on);

        // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
        swipeLayout.setColorScheme(
                android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);

        return view;
    }
}

À la fois la mise en page et la structure de la classe sont les mêmes pour tous les 3 fragments juste avec l'id du changement de nom.Je n'ai vraiment aucune idée de ce qui se passe ici.De nouveau toute aide est grandement appréciée!

Était-ce utile?

La solution

Vous devez utiliser un nom complet du paquet pour SwipeRefreshLayout:

<android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ryan.brooks.fropllc.frop.app.whatsGoingOnFragment"
    android:id="@+id/swipe_refresh_whats_going_on">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#343434"></ScrollView>

</android.support.v4.widget.SwipeRefreshLayout>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top