您的位置:首页 > 编程语言

第一行代码 3.4.2 创建自定义控件 章节中初上手出项的下载完成后闪退问题和自定义控件无反应问题

2017-12-11 18:36 295 查看
关于出项下载后闪退并且打开app时也闪退的问题,主要是xml文件出错,一般情况按照书中的流程title.xml文件是没有错误的,主要原因在于 activity_main.xm了文件中,直接说代码

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

    android:layout_width="match_parent"

    android:layout_height="match_parent"

 /*************************************************************

这一部分是自动生产成的删去的话可能会闪退(我是这样)
***************************************************************/
    android:paddingBottom="@dimen/activity_vertical_margin"

    android:paddingLeft="@dimen/activity_horizontal_margin"

    android:paddingRight="@dimen/activity_horizontal_margin"

    android:paddingTop="@dimen/activity_vertical_margin"

    tools:context="com.example.appof1.MainActivity" >

  /***********************************************************************
这个声明一定要在调用之前声明,否则无效,按键无效的主要原因

**************************************************************************/
    <include layout="@layout/title"/>

/********************************************************************************************************************************

包名一定要写对,书上原文是com.example.uicustomviews.TitleLayout我这里创建的时候是appof1这个写错也也会闪退

************************************************************************************************************************************/

    <com.example.appof1.TitleLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ></com.example.appof1.TitleLayout>
PS.我是新手,如有错误希望大佬指出,非常感谢
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  自定义控件 xml 报错
相关文章推荐