Android code no error, but run error

Source: Internet
Author: User

Rookie after 2 hours of adjustment, it is important to find the problem:

The code does not raise errors, the program always displays errors when running, the error is:

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

If you look at the error, you know that there should be a layout problem, and I have a layout that says:

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

Without putting this include in a layout, the result is a bit of a conflict with the following,

The right way is:

<relativelayout
Android:layout_width= "Fill_parent"
android:layout_height= "50DP"
Android:background= "#ffffff"
>
<include
Android:id= "@+id/chaneltheme"
layout= "@layout/channel_theme"/>
</RelativeLayout>

In this way, the effect is good, will not report errors,

It took the rookie two hours to get to the truth:

1, must learn to see Logcat direction error, do not waste too much time in the right place.

2, Android layout also need to learn well.

Android code no error, but run error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.