Erro no Android ao inflar a classe SwipeRefreshLayout
-
21-12-2019 - |
Pergunta
Estou trabalhando em um aplicativo agora que usa três guias com um fragmento em cada uma e estou tentando implementar SwipeRefreshLayout em cada um desses fragmentos.Acredito que criei isso corretamente, mas continuo recebendo os erros:
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)
Agora não tenho absolutamente nenhuma ideia do que está causando isso.Se alguém pudesse me ajudar, isso seria tremendamente apreciado.
Aqui está o layout do meu fragmento onde estou implementando o 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>
E aqui está minha classe de fragmento onde estou chamando 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;
}
}
Os layouts e a estrutura de classes são exatamente os mesmos para todos os 3 fragmentos, apenas com alterações no nome do ID.Eu realmente não tenho ideia do que está errado aqui.Mais uma vez, qualquer ajuda é muito apreciada!
Solução
Você precisa usar um nome de pacote completo para 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>