У меня есть небольшая проблема с моим Android-приложением. Итак, у меня есть фрагмент карт, и я пытаюсь поставить его под списком. Ошибка возникает при попытке заполнить ListView, он показывает пустой раньше, но как только я привязать его к адаптеру он дает мне эту ошибку:Ошибка раздувания фрагмента класса
01-21 20: 43: 17,635 19597-19597/boxcom.secondattempt E/AndroidRuntime: FATAL EXCEPTION: main 01-21 20: 43: 17.635 19597-19597/boxcom.secondattempt E/AndroidRuntime: Процесс: boxcom.secondattempt, PID: 19597 01-21 20: 43: 17.635 19597 -19597/boxcom.secondattempt E/AndroidRuntime: android.view.InflateException: Binary XML файл строка # 22: Ошибка при наполнении фрагментировать учащемуся
Вот мой XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main_menu" tools:context="boxcom.secondattempt.MainMenu">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/map"
android:layout_alignParentStart="true"
android:layout_marginTop="70dp"
android:weightSum="1">
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="0dp"
class="com.google.android.gms.maps.MapFragment"
android:layout_weight="0.75"
android:layout_gravity="top|bottom"></fragment>
<ListView
android:id="@+id/listv"
android:background="@color/com_facebook_blue"
android:layout_width="354dp"
android:layout_height="187dp"></ListView>
</LinearLayout>
</RelativeLayout>
и где я заселить:
public void init_endroits()
{
Place A = new Place();
Place B = new Place();
Place C = new Place();
A.setName("Café A");
B.setName("Restaurant B");
C.setName("Musée C");
A.setDescription("C'est un café");
B.setDescription("C'est un restaurant");
C.setDescription("C'est un Musée");
ListView LV = (ListView)findViewById(R.id.listv);
Endroits.add(A);
Endroits.add(B);
Endroits.add(C);
adapter = new ArrayAdapter<Place>(this,R.layout.activity_main_menu,Endroits);
LV.setAdapter(adapter);
LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
Place X = Endroits.get(position);
Toast.makeText(MainMenu.this, X.getDescription().toString(), Toast.LENGTH_SHORT).show();
}
});
}
Я называю этот метод после загрузки все, когда я нажимаю кнопку в панели навигации.
Помогите мне пожалуйста?
Какая линия находится в строке 22? – TheSunny
Используете ли вы FragmentActivity? – MikeL
это не в «<фрагмент» – user3591536