gpt4 book ai didi

android - 包括不工作

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:12:52 25 4
gpt4 key购买 nike

我尝试将其设置为我的 Activity 布局:

<?xml version="1.0" encoding="utf-8"?>
<include layout="@layout/map_activity_base" />

如果我使用 @layout/map_activity_base它可以工作,而不是包含它。我不这样做的原因是你不能在大屏幕布局中包含小屏幕布局的内容,但我需要 @layout/map_activity_base 的内容。在不同的布局中。

我得到的错误是

E/AndroidRuntime(11383): FATAL EXCEPTION: main
E/AndroidRuntime(11383): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.l_one.app.achileo/de.l_one.app.achileo.Main}: android.view.InflateException: Binary XML file line #2: Error inflating class include
[...]
E/AndroidRuntime(11383): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class include
[...]
E/AndroidRuntime(11383): Caused by: java.lang.ClassNotFoundException: android.view.include in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/de.l_one.app.achileo-1.apk]

所以android似乎认为<include />应该是 View但这只有在我使用 <include /> 时才会发生没有任何周边View

那么可以使用<include />吗?没有任何周边View如果不是,实现我想要的目标的最佳方式是什么?

顺便说一句:我不知道这是否重要,但这是图书馆项目的内容。

编辑:map_activity_base.xml

<?xml version="1.0" encoding="UTF-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView android:id="@+id/listHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:gravity="center"
android:text="@string/listHeader"
android:padding="5dp" />

<View android:id="@+id/divider"
android:layout_width="100dp"
android:layout_height="1dp"
android:background="#333"
android:layout_below="@id/listHeader" />

<de.l_one.app.map.base.POIListView android:id="@+id/poiList"
android:layout_width="100sp"
android:layout_height="match_parent"
android:divider="#cccccc"
android:dividerHeight="1dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/divider"
android:listSelector="@android:color/transparent" />

<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/poiList"
android:clickable="true"
android:apiKey="@string/googleAPIKey" />

<TextView android:id="@+id/cmtryNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:padding="5dp"
android:background="@drawable/cmtry_txt_view_back" />

<TextView android:id="@+id/navigate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/cmtryNameTextView"
android:padding="5dp"
android:background="@drawable/cmtry_txt_view_back"
android:visibility="gone"
android:text="@string/navigate" />

</RelativeLayout>

最佳答案

我相信您至少需要将“include”放在 Root View 中。类似以下内容:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
...

<include layout="@layout/titlebar"/>

...

/>

关于android - 包括不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12456956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com