Android代碼沒有錯誤,但是運行出錯

來源:互聯網
上載者:User

標籤:android   io   ar   sp   java   on   art   問題   log   

菜鳥經過了2個多小時的調整,重要發現了問題的所在:

代碼沒有提出錯誤,啟動並執行時候程式老是顯示錯誤,提示的錯誤是:

11-24 15:22:16.587: E/AndroidRuntime(19903): FATAL EXCEPTION: main
11-24 15:22:16.587: E/AndroidRuntime(19903): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.shikechannel/com.example.shikechannel.ChannelActivity}: android.view.InflateException: Binary XML file line #40: Error inflating class com.handmark.pulltorefresh.library.PullToRefreshListView

看了錯誤提示就知道應該是是布局方面存在的問題,我的布局中存在:

<include
android:id="@+id/chaneltheme"
layout="@layout/channel_theme" />

沒有把這個include放在一個布局中,結果和下面的有些衝突,

正確的方式是:

<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ffffff"
>
<include
android:id="@+id/chaneltheme"
layout="@layout/channel_theme" />
</RelativeLayout>

 

這樣的話,效果好,才不會報錯誤,

 

菜鳥花了兩個小時才明天的道理:

1、一定學會看LogCat 方向錯誤,不要在正確地方浪費過多的時間。

2、Android布局還要好好的學習學習。

Android代碼沒有錯誤,但是運行出錯

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.