【Android】解决新建的xml文件无法正常加载的问题
新建一个xml布局文件,如下:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:background="#DDDDDD" >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="20dp"
- android:background="#FFFFFF" >
- <TextView
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginLeft="10dp"
- android:text="手机号码"
- android:textSize="11sp" />
- <EditText
- android:id="@+id/EditText01"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:paddingLeft="3dp"
- android:textColor="#999"
- android:textColorHint="#9f9f9f"
- android:textCursorDrawable="@null"
- android:textSize="11sp" />
- <ImageView
- android:id="@+id/imageView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginRight="10dp"
- android:src="@drawable/reg" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="1dp"
- android:background="#FFFFFF" >
- <TextView
- android:id="@+id/txttitlepwd"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="密码"
- android:textSize="11sp"
- android:layout_marginLeft="10dp"/>
- <EditText
- android:id="@+id/txtpassword"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingLeft="3dp"
- android:textColor="#999"
- android:layout_gravity="center"
- android:textColorHint="#9f9f9f"
- android:textCursorDrawable="@null"
- android:textSize="12sp"
- android:layout_marginRight="10dp"/>
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="1dp"
- android:background="#FFFFFF" >
- <TextView
- android:id="@+id/txttitlepwd2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:text="确认密码"
- android:textSize="11sp"
- android:layout_marginLeft="10dp"/>
- <EditText
- android:id="@+id/txtpassword2"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingLeft="3dp"
- android:layout_gravity="center"
- android:textColor="#999"
- android:textColorHint="#9f9f9f"
- android:textCursorDrawable="@null"
- android:textSize="11sp"
- android:layout_marginRight="10dp" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="20dp"
- android:background="#FFFFFF" >
- <TextView
- android:id="@+id/txtemailtitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="邮箱"
- android:layout_gravity="center"
- android:textSize="11sp"
- android:layout_marginLeft="10dp"/>
- <EditText
- android:id="@+id/txtemail"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginRight="10dp"
- android:layout_weight="1"
- android:paddingLeft="3dp"
- android:layout_gravity="center"
- android:textColor="#999"
- android:textColorHint="#9f9f9f"
- android:textCursorDrawable="@null"
- android:textSize="11sp" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="1dp"
- android:background="#FFFFFF" >
- <TextView
- android:id="@+id/txtsextitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginLeft="10dp"
- android:layout_weight="2"
- android:text="性别"
- android:textSize="11sp" />
- <RadioButton
- android:id="@+id/rdbMen"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_weight="3"
- android:text="男"
- android:textSize="11sp" />
- <RadioButton
- android:id="@+id/rdbWoMen"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_weight="3"
- android:text="女"
- android:textSize="11sp"
- android:layout_marginRight="10dp" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="1dp"
- android:background="#FFFFFF" >
- <TextView
- android:id="@+id/txtaddresstitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginLeft="10dp"
- android:text="所在地"
- android:textSize="11sp" />
- <EditText
- android:id="@+id/txteaddress"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginRight="10dp"
- android:layout_weight="1"
- android:paddingLeft="3dp"
- android:layout_gravity="center"
- android:textColor="#999"
- android:textColorHint="#9f9f9f"
- android:textCursorDrawable="@null"
- android:textSize="11sp" />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="20dp"
- android:layout_marginTop="50dp"
- android:background="#DDDDDD" >
- <Button
- android:id="@+id/button1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="#FF0000"
- android:text="下一步"
- android:textColor="#FFFFFF"
- android:textSize="11sp" />
- </LinearLayout>
- </LinearLayout>
执行一个函数调用此xml文件的时候,整个app直接死掉,调用代码如下:
- void register() {
- this.Close();
- Intent intent = new Intent();
- intent.setClass(this, RegisterUsers.class);
- startActivity(intent);
- }
- 注:RegisterUsers 就是新建的xml文件。
解决办法如下:新建的xml文件必须提前声明,最简单的方法就是直接在配置文件中定义,如下:
在application节点中增加如下代码:
- <activity android:name="com.pk.view.RegisterUsers"></activity>
问题解决!!!
【Android】解决新建的xml文件无法正常加载的问题的更多相关文章
- Android xmlpull 方式解析xml文件
1.新建一个xml文件,放在res/xml目录下 <?xml version="1.0" encoding="utf-8"?> <citys& ...
- Android color(颜色) 在XML文件和java代码中
Android color(颜色) 在XML文件和java代码中,有需要的朋友可以参考下. 1.使用Color类的常量,如: int color = Color.BLUE;//创建一个蓝色 是使用An ...
- Android开发之获取xml文件的输入流对象
介绍两种Android开发中获取xml文件的输入流对象 第一种:通过assets目录获取 1.首先是在Project下app/src/main目录下创建一个assets文件夹,将需要获取的xml文件放 ...
- Android UI--自定义ListView(实现下拉刷新+加载更多)
Android UI--自定义ListView(实现下拉刷新+加载更多) 关于实现ListView下拉刷新和加载更多的实现,我想网上一搜就一堆.不过我就没发现比较实用的,要不就是实现起来太复杂,要不就 ...
- 【技术贴】第二篇 :解决使用maven jetty启动后无法加载修改过后的静态资源
之前写过第一篇:[技术贴]解决使用maven jetty启动后无法加载修改过后的静态资源 一直用着挺舒服的,直到今天,出现了又不能修改静态js,jsp等资源的现象.很是苦闷. 经过调错处理之后,发现是 ...
- 如何使用 require.js ,实现js文件的异步加载,避免网页失去响应,管理模块之间的依赖性,便于代码的编写和维护。
一.为什么要用require.js? 最早的时候,所有Javascript代码都写在一个文件里面,只要加载这一个文件就够了.后来,代码越来越多,一个文件不够了,必须分成多个文件,依次加载.下面的网页代 ...
- Android图片管理组件(双缓存+异步加载)
转自:http://www.oschina.net/code/snippet_219356_18887?p=3#comments ImageManager2这个类具有异步从网络下载图片,从sd读取本地 ...
- android 在自定义的listview(有刷新加载项)列表中,数据过少时不能铺满整个屏幕时,header和footer同时显示问题
android 在自定义的listview(有刷新加载项)列表中,数据过少时,当刷新时,加载项也会显示,这是很头疼的一个问题,查阅了一些资料,总结了一个比较不错的方法: 原来代码: @Overrid ...
- profile文件的错误加载与基本命令间的映射
一.绪论 [因为这篇心得是原创的,所以如果有哪处总结或者意见不足的地方,欢迎各位大神的批评和意见,共同学习,谢谢了!] 早些时候,需要在centos6.4系统中配置单机版和集群版单节点的hadoop ...
随机推荐
- DataList 用法详解
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataList.aspx. ...
- 使用nginx-http-concat添加nginx资源请求合并功能
web项目中有时候一个页面会加载多个js或css资源请求,导致页面加载耗时较长,这时优化的方向可以采用资源合并,可以在客户端事先合并,也可以在服务端进行资源合并,服务端合并的方式使用起来更灵活. ng ...
- Django根据现有数据库建立model
Django引入外部数据库还是比较方便的,步骤如下 创建一个项目,修改seting文件,在setting里面设置你要连接的数据库类型和连接名称,地址之类,和创建新项目的时候一致 运行下面代码可以自动生 ...
- 侣行APP
本次要做的是团队共同完成一个项目.由队长组织,全体队员一起讨论分析并完成一款APP的需求调研,分析等工作. 1.团队介绍 队长:杨晓帅 队员 ...
- TIJ——Chapter Eight:Polymorphism
The twist |_Method-call binding Connecting a method call to a method body is called binding. When bi ...
- C++之路进阶codevs1242(布局)
1242 布局 2005年USACO 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold <:section class="hbox" ...
- Java 线程的转换及状态
线程的状态转换是线程控制的基础. 线程状态总的可分为五大状态:分别是生.死.可运行.运行.等待/阻塞.用一个图来描述如下: 1.新建状态(New):新创建了一个线程对象. 2.就绪状态(Runnabl ...
- PL/SQL Developer安装详解(32位客户端免安装版)
PL/SQL Developer是一个集成开发环境,专门开发面向Oracle数据库的应用.PL/SQL也是一种程序语言,叫做过程化SQL语言(Procedural Language/SQL).PL/S ...
- peoplesoft SQR language
Understanding SQR Data Elements !Variables!Variables are storage places for text or numbers that you ...
- Tomcat 常用配置及网站部署
一.同一Tomcat 多个端口部署不同的项目 在tomcat 安装目录下C:/Program Files/apache-tomcat-6.0.29/conf找到server.xml (1 ...