第一行程式碼 3.4.2 建立自定義控制元件 章節中初上手出項的下載完成後閃退問題和自定義控制元件無反應問題
關於出項下載後閃退並且開啟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.我是新手,如有錯誤希望大佬指出,非常感謝