第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

android.view.InflateException:二進(jìn)制XML文件:夸大類片段的錯(cuò)誤

android.view.InflateException:二進(jìn)制XML文件:夸大類片段的錯(cuò)誤

桃花長(zhǎng)相依 2019-09-24 09:56:18
我有一個(gè)非常令人沮喪的錯(cuò)誤,無法解釋。我創(chuàng)建了一個(gè)Android應(yīng)用程序,用于Android AppCompat使其與舊版本兼容。這是我的主要活動(dòng)布局文件:<android.support.v4.widget.DrawerLayout    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/drawer_layout"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">    <!-- As the main content view, the view below consumes the entire         space available using match_parent in both dimensions. -->    <FrameLayout        android:id="@+id/container"        android:layout_width="match_parent"        android:layout_height="match_parent" />    <!-- android:layout_gravity="start" tells DrawerLayout to treat         this as a sliding drawer on the left side for left-to-right         languages and on the right side for right-to-left languages.         If you're not building against API 17 or higher, use         android:layout_gravity="left" instead. -->    <!-- The drawer is given a fixed width in dp and extends the full height of         the container. -->    <fragment android:id="@+id/navigation_drawer"        android:layout_width="@dimen/navigation_drawer_width"        android:layout_height="match_parent"        android:layout_gravity="start"        android:name="com.fragment.NavigationDrawerFragment" /></android.support.v4.widget.DrawerLayout>這是我的活動(dòng)的主要代碼:public class MainActivity extends ActionBarActivity {@Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);   }}這里的主要問題是:上面的代碼在幾乎所有設(shè)備(受激設(shè)備或某些實(shí)際設(shè)備)上都能流暢運(yùn)行。但是當(dāng)我在三星S3上運(yùn)行它時(shí)。它注意到此錯(cuò)誤:java.lang.RuntimeException: Unable to start activity ComponentInfo{view.MainActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class fragment           請(qǐng)告訴我如何解決錯(cuò)誤,謝謝:)
查看完整描述

3 回答

?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊

經(jīng)過長(zhǎng)時(shí)間的調(diào)試,我已解決此問題。(盡管我仍然無法解釋原因)。我將財(cái)產(chǎn)更改android:name為class。(盡管在Android Document上,他們說這些屬性是相同的,但是可以正常使用!?。。?/p>


因此,它應(yīng)從:


 android:name="com.fragment.NavigationDrawerFragment"


class = "com.fragment.NavigationDrawerFragment"

因此,新布局應(yīng)為:


<!-- As the main content view, the view below consumes the entire

     space available using match_parent in both dimensions. -->

<FrameLayout

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent" />


<!-- android:layout_gravity="start" tells DrawerLayout to treat

     this as a sliding drawer on the left side for left-to-right

     languages and on the right side for right-to-left languages.

     If you're not building against API 17 or higher, use

     android:layout_gravity="left" instead. -->


<!-- The drawer is given a fixed width in dp and extends the full height of

     the container. -->

<fragment android:id="@+id/navigation_drawer"

    android:layout_width="@dimen/navigation_drawer_width"

    android:layout_height="match_parent"

    android:layout_gravity="start"

    class = "com.fragment.NavigationDrawerFragment" />

希望這個(gè)幫助:)


查看完整回答
反對(duì) 回復(fù) 2019-09-24
?
largeQ

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊

我無法使用提供的答案解決問題。最后我改變了這個(gè):


<fragment

android:id="@+id/fragment_food_image_gallery"

android:name="ir.smartrestaurant.ui.fragment.ImageGalleryFragment"

android:layout_width="match_parent"

android:layout_height="200dp"

android:layout="@layout/fragment_image_gallery"

tools:layout="@layout/fragment_image_gallery" />

對(duì)此:


<FrameLayout

android:id="@+id/fragment_container"

android:layout_width="match_parent"

android:layout_height="200dp" />

,


private void showGallery() {

    ImageGalleryFragment fragment = new ImageGalleryFragment()

    getSupportFragmentManager().beginTransaction()

                .replace(R.id.fragment_container, fragment)

                .commit();

    }

而且有效。

如果在片段中使用它,請(qǐng)使用getChildFragmentManager而不是getSupportFragmentManager。


查看完整回答
反對(duì) 回復(fù) 2019-09-24
?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊

我遇到了同樣的問題,問題,嘗試了該線程中的所有答案,但無濟(jì)于事。我的解決方案是,我沒有在Activity XML中添加ID。我認(rèn)為這并不重要,但確實(shí)如此。


因此,在活動(dòng)XML中,我有:


<fragment

    android:name="com.covle.hellocarson.SomeFragment"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

但是應(yīng)該有:


<fragment

    android:id="@+id/some_fragment"

    android:name="com.covle.hellocarson.SomeFragment"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"/>

如果有人樂于對(duì)這是為什么發(fā)表評(píng)論,我想向其他人說,我希望這會(huì)有所幫助。


查看完整回答
反對(duì) 回復(fù) 2019-09-24
  • 3 回答
  • 0 關(guān)注
  • 621 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)