Ошибка Android накаляет Swiperefreshlayout
-
21-12-2019 - |
Вопрос
Я работаю над приложением прямо сейчас, в котором используется 3 вкладка с фрагментом в каждом, и я пытаюсь реализовать Swiperefreshlayout в каждом из этих фрагментов.Я верю, что я создал это правильно, но я продолжаю получать ошибки:
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)
.
Теперь я не имею никакой идеи, что вызывает это.Если кто-то может помочь мне, это было бы огромно оценено.
Вот мой макет фрагментов, где я реализую 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>
.
А вот мой класс фрагмента, где я звоню в 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;
}
}
.
Оба компоновки, так и структура классов - это то же самое для всех трех фрагментов только с изменениями имени ID.У меня действительно нет никакой подсказки, что здесь не так.Снова любая помощь очень ценится!
Решение
Вам нужно использовать полное имя пакета для 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>
.