没有';“找不到类”;android.view.fragment“;
我得到了错误信息: 原因:android.view.InflateException:二进制XML文件行#1: 膨胀类片段时出错,原因是: java.lang.ClassNotFoundException:未找到类 路径:DexPathList[[zip文件]上的“android.view.fragment” “/data/app/com.rankov.maplistener-1/base.apk”],NativeLibraryDirectory=[/vendor/lib, /系统/库]] 在这条线上没有';“找不到类”;android.view.fragment“;,android,android-fragments,Android,Android Fragments,我得到了错误信息: 原因:android.view.InflateException:二进制XML文件行#1: 膨胀类片段时出错,原因是: java.lang.ClassNotFoundException:未找到类 路径:DexPathList[[zip文件]上的“android.view.fragment” “/data/app/com.rankov.maplistener-1/base.apk”],NativeLibraryDirectory=[/vendor/lib, /系统/库]] 在这
inflate(getContext(), R.layout.activity_maps, this);
这是我的xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.rankov.maplistener.MapsActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/abc_popup_background_mtrl_mult">
<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<Button
android:id="@+id/button_done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:background="@drawable/abc_popup_background_mtrl_mult"
android:text="@string/done" />
</RelativeLayout>
</fragment>
从这个活动开始
public class MapsActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_view);
//setContentView(R.layout.activity_maps);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.test_layout);
MapsView mView = new MapsView(getApplicationContext());
layout.addView(mView);
}
}
问题是什么?请检查是否所有片段引用都是View.fragment或support.v4.app.fragment,而不是两者的混合both@SarahMaher我只导入PlaceAutocompleteFragment和SupportMapFragment;此外,我对这些片段使用不同的碎片管理器(android.support.v4.app.FragmentManager和android.app.FragmentManager)。可以吗?
public class MapsActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_view);
//setContentView(R.layout.activity_maps);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.test_layout);
MapsView mView = new MapsView(getApplicationContext());
layout.addView(mView);
}
}