2012-11-11 66 views
1

編輯:我刪除了我的異常信息。在@Sam的幫助下,我能夠使用修復項目屬性,並且應用程序不再強制關閉我。雖然,從圖像textview到textview圖像重新排列布局會導致它不顯示圖像。有誰知道爲什麼?所有的代碼都可以在這裏http://www.ezzylearning.com/tutorial.aspx?tid=1763429自定義列表適配器不會顯示圖片

發現我試圖遵循本教程 http://www.ezzylearning.com/tutorial.aspx?tid=1763429我有 作爲一切工作的發佈。我採用這個更復雜的 佈局。我試圖改變一些非常簡單的東西。我從左到右移動了圖像 。

<ImageView android:id="@+id/imgIcon" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:gravity="center_vertical" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentBottom="true" 
    android:layout_marginRight="15dp" 
    android:layout_marginTop="5dp" 
    android:layout_marginBottom="5dp" /> 

<TextView android:id="@+id/txtTitle" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="center_vertical" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentBottom="true" 
    android:textStyle="bold" 
    android:textSize="22dp" 
    android:textColor="#000000" 
    android:layout_marginTop="5dp" 
    android:layout_marginBottom="5dp" /> 

 <TextView android:id="@+id/txtTitle" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center_vertical" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentBottom="true" 
     android:textStyle="bold" 
     android:textSize="22dp" 
     android:textColor="#000000" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" /> 

    <ImageView android:id="@+id/imgIcon" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:gravity="center_vertical" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentBottom="true" 
     android:layout_marginRight="15dp" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" /> 
+1

重新排列這樣的XML不應該導致您的應用程序崩潰,還會發生其他事情。發佈你的'getView()'方法並將你的LogCat錯誤剪切並粘貼到問題中。 (你的截圖不完整......) – Sam

+0

我的觀點正確。它應該通過ID找到所有東西,爲什麼它會失敗?我已更新了所需的信息。 –

+0

@Sam你是如何添加滾動的?只是格式化爲代碼? –

回答

1

這沒有任何意義!

  • 嘗試清潔您的項目:項目 - 從Android的工具

>清潔...

  • 或者使用修復屬性還您的ImageView和TextView的是坐在您可能希望將android:layout_width="wrap_content"android:layout_weight="5"添加到ImageView的TextView和android:layout_weight="1"。 ... :)

  • +0

    它與Fix Properties有關,然後是Project-> Clean,但這是讓我嘗試其他的關鍵事情。這一切都歸結爲日食是一個可怕的糟糕的IDE和谷歌/安卓沒有足夠關心他們的開發人員提供一個IDE的重量在狗屎更不用說黃金。 –

    +0

    對於任何對activity_main或layout行的編輯,該事情都會繼續執行此操作。這太奇怪了。我認爲這將是一次性的,但似乎是一個錯誤。 –

    +1

    這是奇怪的,而不是正常的行爲。然而這樣的問題不是我的專長。我只能說「那不應該發生」......嘗試發佈新的問題,詳細說明如何創建此錯誤,但用[eclipse]標記新問題。 – Sam

    1

    我有類似的問題,雖然有不同的組件。

    什麼爲我工作,不知道爲什麼重新安排xml文件。放置ImageViewTextView 含義之前,

    <ImageView android:id="@+id/imgIcon" 
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent" 
        android:gravity="center_vertical" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentBottom="true" 
        android:layout_marginRight="15dp" 
        android:layout_marginTop="5dp" 
        android:layout_marginBottom="5dp" /> 
    
    <TextView android:id="@+id/txtTitle" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:gravity="center_vertical" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentBottom="true" 
        android:textStyle="bold" 
        android:textSize="22dp" 
        android:textColor="#000000" 
        android:layout_marginTop="5dp" 
        android:layout_marginBottom="5dp" /> 
    
    +0

    謝謝,但這是如何設置原始教程。我可以通過訂購像這樣的佈局元素來解決這個問題,但這並不能幫助我,對不起。我需要知道如何重新排列,以便我可以構建自定義用戶界面。我相信它與行項目有關。我實際上不是在查看listView佈局內部,而是查看包含標籤錯誤項目的運行時對象行。我將嘗試執行堆棧跟蹤以查看調用getView的函數,以試圖查看是否可以看到爲什麼這些項目被錯誤標記。謝謝! –

    1

    你不應該做

    row = inflater.inflate(layoutResourceId, parent, false); 
    

    row = inflater.inflate(layoutResourceId, null, false); 
    

    這可能是原因。我已經有例外了。

    +0

    奇怪的是,我沒有得到一個例外,這種變化沒有任何不同。你知道爲什麼它應該是這樣嗎?我正在使用API​​ 8,你呢? –

    +1

    我不記得是什麼例外,也不知道爲什麼會發生這種情況,但有時編碼實際上很奇怪。它在API 7上。 – Flawyte

    +0

    有時候編碼是非常奇怪的......我聽過的最真實的陳述 –

    相關問題