Android XML中的片段标记在片段类中不起作用
下面是调用包含标记的XML的片段类Android XML中的片段标记在片段类中不起作用,android,xml,android-layout,android-fragments,Android,Xml,Android Layout,Android Fragments,下面是调用包含标记的XML的片段类 public class FragmentAbout extends Fragment { public FragmentAbout(){} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView =
public class FragmentAbout extends Fragment {
public FragmentAbout(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_about, container, false);
return rootView;
}
}
下面是包含标记的XML文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FragmentTripPlan" >
<fragment
android:id="@+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/btn_draw"
android:layout_alignParentLeft="true"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
我该怎么修这个?
非常感谢!
XML中的片段标记在片段类中不起作用
import android.support.v4.app.Fragment;
您的活动必须扩展FragmentActivity
FragmentAbout
是添加到活动xml ie FrameLayout中容器中的片段
您还应该使用MapView
。您可以找到类似的示例@
向我们展示导入语句和活动代码您想要片段中的映射吗?@Raghunandan是的,先生。我正在尝试将我的FragmentActivity类代码转换为FragmentClass。为此,您应该使用
MapView
,因此我将使用MapView?谢谢,先生。在我再次询问之前,我会先尝试一下。
import android.support.v4.app.Fragment;