I have a little issue with my android app. So i have a maps fragment, and i'm trying to put a listview under it. The error occurs when i Try to populate the listview, it does show empty before, but once i bind it to the adapter it gives me this error :
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: Process: boxcom.secondattempt, PID: 19597 01-21 20:43:17.635 19597-19597/boxcom.secondattempt E/AndroidRuntime: android.view.InflateException: Binary XML file line #22: Error inflating class fragment
Here is my 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>
and where I populate :
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();
}
});
}
I call this method after everything is loaded, when I press a button in the navbar.
Can you help me please?