新建一个xml布局文件,如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical"
  6. android:background="#DDDDDD" >
  7.  
  8. <LinearLayout
  9. android:layout_width="match_parent"
  10. android:layout_height="40dp"
  11. android:layout_marginLeft="20dp"
  12. android:layout_marginRight="20dp"
  13. android:layout_marginTop="20dp"
  14. android:background="#FFFFFF" >
  15.  
  16. <TextView
  17. android:id="@+id/textView1"
  18. android:layout_width="wrap_content"
  19. android:layout_height="wrap_content"
  20. android:layout_gravity="center"
  21. android:layout_marginLeft="10dp"
  22. android:text="手机号码"
  23. android:textSize="11sp" />
  24.  
  25. <EditText
  26. android:id="@+id/EditText01"
  27. android:layout_width="fill_parent"
  28. android:layout_height="wrap_content"
  29. android:layout_gravity="center"
  30. android:layout_weight="1"
  31. android:paddingLeft="3dp"
  32. android:textColor="#999"
  33. android:textColorHint="#9f9f9f"
  34. android:textCursorDrawable="@null"
  35. android:textSize="11sp" />
  36.  
  37. <ImageView
  38. android:id="@+id/imageView1"
  39. android:layout_width="wrap_content"
  40. android:layout_height="wrap_content"
  41. android:layout_gravity="center"
  42. android:layout_marginRight="10dp"
  43. android:src="@drawable/reg" />
  44.  
  45. </LinearLayout>
  46.  
  47. <LinearLayout
  48. android:layout_width="match_parent"
  49. android:layout_height="40dp"
  50. android:layout_marginLeft="20dp"
  51. android:layout_marginRight="20dp"
  52. android:layout_marginTop="1dp"
  53. android:background="#FFFFFF" >
  54.  
  55. <TextView
  56. android:id="@+id/txttitlepwd"
  57. android:layout_width="wrap_content"
  58. android:layout_height="wrap_content"
  59. android:layout_gravity="center"
  60. android:text="密码"
  61. android:textSize="11sp"
  62. android:layout_marginLeft="10dp"/>
  63.  
  64. <EditText
  65. android:id="@+id/txtpassword"
  66. android:layout_width="fill_parent"
  67. android:layout_height="wrap_content"
  68. android:layout_weight="1"
  69. android:paddingLeft="3dp"
  70. android:textColor="#999"
  71. android:layout_gravity="center"
  72. android:textColorHint="#9f9f9f"
  73. android:textCursorDrawable="@null"
  74. android:textSize="12sp"
  75. android:layout_marginRight="10dp"/>
  76.  
  77. </LinearLayout>
  78.  
  79. <LinearLayout
  80. android:layout_width="match_parent"
  81. android:layout_height="40dp"
  82. android:layout_marginLeft="20dp"
  83. android:layout_marginRight="20dp"
  84. android:layout_marginTop="1dp"
  85. android:background="#FFFFFF" >
  86.  
  87. <TextView
  88. android:id="@+id/txttitlepwd2"
  89. android:layout_width="wrap_content"
  90. android:layout_height="wrap_content"
  91. android:layout_gravity="center"
  92. android:text="确认密码"
  93. android:textSize="11sp"
  94. android:layout_marginLeft="10dp"/>
  95.  
  96. <EditText
  97. android:id="@+id/txtpassword2"
  98. android:layout_width="fill_parent"
  99. android:layout_height="wrap_content"
  100. android:layout_weight="1"
  101. android:paddingLeft="3dp"
  102. android:layout_gravity="center"
  103. android:textColor="#999"
  104. android:textColorHint="#9f9f9f"
  105. android:textCursorDrawable="@null"
  106. android:textSize="11sp"
  107. android:layout_marginRight="10dp" />
  108.  
  109. </LinearLayout>
  110.  
  111. <LinearLayout
  112. android:layout_width="match_parent"
  113. android:layout_height="40dp"
  114. android:layout_marginLeft="20dp"
  115. android:layout_marginRight="20dp"
  116. android:layout_marginTop="20dp"
  117. android:background="#FFFFFF" >
  118.  
  119. <TextView
  120. android:id="@+id/txtemailtitle"
  121. android:layout_width="wrap_content"
  122. android:layout_height="wrap_content"
  123. android:text="邮箱"
  124. android:layout_gravity="center"
  125. android:textSize="11sp"
  126. android:layout_marginLeft="10dp"/>
  127.  
  128. <EditText
  129. android:id="@+id/txtemail"
  130. android:layout_width="fill_parent"
  131. android:layout_height="wrap_content"
  132. android:layout_marginRight="10dp"
  133. android:layout_weight="1"
  134. android:paddingLeft="3dp"
  135. android:layout_gravity="center"
  136. android:textColor="#999"
  137. android:textColorHint="#9f9f9f"
  138. android:textCursorDrawable="@null"
  139. android:textSize="11sp" />
  140.  
  141. </LinearLayout>
  142.  
  143. <LinearLayout
  144. android:layout_width="match_parent"
  145. android:layout_height="40dp"
  146. android:layout_marginLeft="20dp"
  147. android:layout_marginRight="20dp"
  148. android:layout_marginTop="1dp"
  149. android:background="#FFFFFF" >
  150.  
  151. <TextView
  152. android:id="@+id/txtsextitle"
  153. android:layout_width="wrap_content"
  154. android:layout_height="wrap_content"
  155. android:layout_gravity="center"
  156. android:layout_marginLeft="10dp"
  157. android:layout_weight="2"
  158. android:text="性别"
  159. android:textSize="11sp" />
  160.  
  161. <RadioButton
  162. android:id="@+id/rdbMen"
  163. android:layout_width="wrap_content"
  164. android:layout_height="wrap_content"
  165. android:layout_gravity="center"
  166. android:layout_weight="3"
  167. android:text="男"
  168. android:textSize="11sp" />
  169.  
  170. <RadioButton
  171. android:id="@+id/rdbWoMen"
  172. android:layout_width="wrap_content"
  173. android:layout_height="wrap_content"
  174. android:layout_gravity="center"
  175. android:layout_weight="3"
  176. android:text="女"
  177. android:textSize="11sp"
  178. android:layout_marginRight="10dp" />
  179.  
  180. </LinearLayout>
  181.  
  182. <LinearLayout
  183. android:layout_width="match_parent"
  184. android:layout_height="40dp"
  185. android:layout_marginLeft="20dp"
  186. android:layout_marginRight="20dp"
  187. android:layout_marginTop="1dp"
  188. android:background="#FFFFFF" >
  189.  
  190. <TextView
  191. android:id="@+id/txtaddresstitle"
  192. android:layout_width="wrap_content"
  193. android:layout_height="wrap_content"
  194. android:layout_gravity="center"
  195. android:layout_marginLeft="10dp"
  196.  
  197. android:text="所在地"
  198. android:textSize="11sp" />
  199. <EditText
  200. android:id="@+id/txteaddress"
  201. android:layout_width="fill_parent"
  202. android:layout_height="wrap_content"
  203. android:layout_marginRight="10dp"
  204. android:layout_weight="1"
  205. android:paddingLeft="3dp"
  206. android:layout_gravity="center"
  207. android:textColor="#999"
  208. android:textColorHint="#9f9f9f"
  209. android:textCursorDrawable="@null"
  210. android:textSize="11sp" />
  211.  
  212. </LinearLayout>
  213.  
  214. <LinearLayout
  215. android:layout_width="match_parent"
  216. android:layout_height="40dp"
  217. android:layout_marginLeft="20dp"
  218. android:layout_marginRight="20dp"
  219. android:layout_marginTop="50dp"
  220. android:background="#DDDDDD" >
  221.  
  222. <Button
  223. android:id="@+id/button1"
  224. android:layout_width="fill_parent"
  225. android:layout_height="wrap_content"
  226. android:background="#FF0000"
  227. android:text="下一步"
  228. android:textColor="#FFFFFF"
  229. android:textSize="11sp" />
  230.  
  231. </LinearLayout>
  232.  
  233. </LinearLayout>

执行一个函数调用此xml文件的时候,整个app直接死掉,调用代码如下:

  1. void register() {
  2. this.Close();
  3. Intent intent = new Intent();
  4. intent.setClass(this, RegisterUsers.class);
  5. startActivity(intent);
  6. }
  1. 注:RegisterUsers 就是新建的xml文件。
    解决办法如下:新建的xml文件必须提前声明,最简单的方法就是直接在配置文件中定义,如下:
    application节点中增加如下代码:
  1. <activity android:name="com.pk.view.RegisterUsers"></activity>

问题解决!!!

【Android】解决新建的xml文件无法正常加载的问题的更多相关文章

  1. Android xmlpull 方式解析xml文件

    1.新建一个xml文件,放在res/xml目录下 <?xml version="1.0" encoding="utf-8"?> <citys& ...

  2. Android color(颜色) 在XML文件和java代码中

    Android color(颜色) 在XML文件和java代码中,有需要的朋友可以参考下. 1.使用Color类的常量,如: int color = Color.BLUE;//创建一个蓝色 是使用An ...

  3. Android开发之获取xml文件的输入流对象

    介绍两种Android开发中获取xml文件的输入流对象 第一种:通过assets目录获取 1.首先是在Project下app/src/main目录下创建一个assets文件夹,将需要获取的xml文件放 ...

  4. Android UI--自定义ListView(实现下拉刷新+加载更多)

    Android UI--自定义ListView(实现下拉刷新+加载更多) 关于实现ListView下拉刷新和加载更多的实现,我想网上一搜就一堆.不过我就没发现比较实用的,要不就是实现起来太复杂,要不就 ...

  5. 【技术贴】第二篇 :解决使用maven jetty启动后无法加载修改过后的静态资源

    之前写过第一篇:[技术贴]解决使用maven jetty启动后无法加载修改过后的静态资源 一直用着挺舒服的,直到今天,出现了又不能修改静态js,jsp等资源的现象.很是苦闷. 经过调错处理之后,发现是 ...

  6. 如何使用 require.js ,实现js文件的异步加载,避免网页失去响应,管理模块之间的依赖性,便于代码的编写和维护。

    一.为什么要用require.js? 最早的时候,所有Javascript代码都写在一个文件里面,只要加载这一个文件就够了.后来,代码越来越多,一个文件不够了,必须分成多个文件,依次加载.下面的网页代 ...

  7. Android图片管理组件(双缓存+异步加载)

    转自:http://www.oschina.net/code/snippet_219356_18887?p=3#comments ImageManager2这个类具有异步从网络下载图片,从sd读取本地 ...

  8. android 在自定义的listview(有刷新加载项)列表中,数据过少时不能铺满整个屏幕时,header和footer同时显示问题

    android  在自定义的listview(有刷新加载项)列表中,数据过少时,当刷新时,加载项也会显示,这是很头疼的一个问题,查阅了一些资料,总结了一个比较不错的方法: 原来代码: @Overrid ...

  9. profile文件的错误加载与基本命令间的映射

    一.绪论 [因为这篇心得是原创的,所以如果有哪处总结或者意见不足的地方,欢迎各位大神的批评和意见,共同学习,谢谢了!] 早些时候,需要在centos6.4系统中配置单机版和集群版单节点的hadoop ...

随机推荐

  1. DataList 用法详解

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataList.aspx. ...

  2. 使用nginx-http-concat添加nginx资源请求合并功能

    web项目中有时候一个页面会加载多个js或css资源请求,导致页面加载耗时较长,这时优化的方向可以采用资源合并,可以在客户端事先合并,也可以在服务端进行资源合并,服务端合并的方式使用起来更灵活. ng ...

  3. Django根据现有数据库建立model

    Django引入外部数据库还是比较方便的,步骤如下 创建一个项目,修改seting文件,在setting里面设置你要连接的数据库类型和连接名称,地址之类,和创建新项目的时候一致 运行下面代码可以自动生 ...

  4. 侣行APP

    本次要做的是团队共同完成一个项目.由队长组织,全体队员一起讨论分析并完成一款APP的需求调研,分析等工作. 1.团队介绍 队长:杨晓帅 队员                               ...

  5. TIJ——Chapter Eight:Polymorphism

    The twist |_Method-call binding Connecting a method call to a method body is called binding. When bi ...

  6. C++之路进阶codevs1242(布局)

    1242 布局 2005年USACO  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold    <:section class="hbox" ...

  7. Java 线程的转换及状态

    线程的状态转换是线程控制的基础. 线程状态总的可分为五大状态:分别是生.死.可运行.运行.等待/阻塞.用一个图来描述如下: 1.新建状态(New):新创建了一个线程对象. 2.就绪状态(Runnabl ...

  8. PL/SQL Developer安装详解(32位客户端免安装版)

    PL/SQL Developer是一个集成开发环境,专门开发面向Oracle数据库的应用.PL/SQL也是一种程序语言,叫做过程化SQL语言(Procedural Language/SQL).PL/S ...

  9. peoplesoft SQR language

    Understanding SQR Data Elements !Variables!Variables are storage places for text or numbers that you ...

  10. Tomcat 常用配置及网站部署

    一.同一Tomcat  多个端口部署不同的项目       在tomcat 安装目录下C:/Program Files/apache-tomcat-6.0.29/conf找到server.xml (1 ...