03 2013 档案
摘要:package com.will.popupwindow;import android.os.Bundle;import android.app.Activity;import android.graphics.drawable.BitmapDrawable;import android.view.Gravity;import android.view.LayoutInflater;import android.view.Menu;import android.view.MotionEvent;import android.view.View;import android.view.View.
阅读全文
摘要:tabhost有两种创建方式,第一种,在activity中继承TabActivity类,然后编写如下的代码就可以创建tabhostpackage com.example.tabhosttest;import android.os.Bundle;import android.app.TabActivity;import android.content.Intent;import android.widget.RadioGroup;import android.widget.RadioGroup.OnCheckedChangeListener;import android.widget.TabHo
阅读全文
摘要:HTTP协议中GET、POST和HEAD的介绍GET: 请求指定的页面信息,并返回实体主体。HEAD: 只请求页面的首部。POST: 请求服务器接受所指定的文档作为对所标识的URI的新的从属实体。 HTTP 定义了与服务器交互的不同方法,最基本的方法是 GET 和 POST。事实上 GET 适用于多数请求,而保留 POST仅用于更新站点。根据 HTTP 规范,GET 用于信息获取,而且应该是安全的和幂等的。所谓安全的意味着该操作用于获取信息而非修改信息。换句话说,GET 请求一般不应产生副作用。幂等的意味着对同一 URL的多个请求应该返回同样的结果。完整的定义并不像看起来那样严格...
阅读全文
摘要:JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。JSON建构有两种结构:json简单说就是javascript中的对象和数组,所以这两种结构就是对象和数组2种结构,通过这两种结构可以表示各种复杂的结构1、对象:对象在js中表示为“{}”扩起来的内容,数据结构为 {key:value,key:value,...}的键值对的结构,在面向对象的语言中,key为对象的属性,value为对应的属性值,所以很容易理解,取值方法为 对象.key 获取属性值,这个属性值的类型可以是 数字、字符串、数组、对象几种。2、数组:数组在js中是中括号“[]”扩起来的内容,
阅读全文
摘要:利用pull解析,将获取到的xml显示在页面中。package com.will.entity;public class Books { private Integer bookId; private String bookName; private float bookPrice; public Books() { super(); } public Integer getBookId() { return bookId; } public void setBookId(Integer bookId) { ...
阅读全文
摘要:<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" tools:context=".MainActivity" > <Button androi
阅读全文
摘要:<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" tools:context=".MainActivity" > <Button androi
阅读全文
摘要:Android预定义样式对于能够显示文字的控件(如TextView EditText RadioButton Button CheckBox Chronometer等等)你有时需要控制字体的大小。Android平台定义了三种字体大小。"?android:attr/textAppearanceLarge""?android:attr/textAppearanceMedium""?android:attr/textAppearanceSmall"使用方法为:android:textAppearance="?android:att
阅读全文
摘要:在listview中添加子listview组件package cn.core.test;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.ExpandableListView;import android.widget.ExpandableListView.OnChildClickListener;import android.widget.ExpandableListView.OnGroupCli
阅读全文
摘要:点击屏幕中的按钮,然后就获取到图片在页面中显示出来<LinearLayout 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:orientation="vertical"
阅读全文
摘要:在res目录下,有一个values的目录,里面有一个statle.xml文件,里面存放的是android的样式,各种样式,包括主题,等等<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="gangnanstyle"> <item name="android:textColor">#ff0000</item> <item name="android:textS
阅读全文
摘要:<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" tools:context=".MainActivity" > <Button androi
阅读全文
摘要:pull解析在android中是一个很重要的解析xml工具,相对其dom还有sax,这个的重要性是不言而喻的。pull解析可以这样用,在res资源目录中创建raw目录,然后在里面创建一个文件 1 <?xml version="1.0" encoding="utf-8"?> 2 <books> 3 <book id='1'> 4 <name>java精通11</name> 5 <price>35.4</price> 6 </book> 7 <
阅读全文
摘要:SAX(simple API for XML)是一种XML解析的替代方法。相比于DOM,SAX是一种速度更快,更有效的方法。在res资源目录下创建一个叫做raw的文件夹,在文件夹中创建如下的xml文件<?xml version="1.0" encoding="utf-8"?><persons> <person id='1'> <name>小王</name> <age>19</age> <sex>男</sex> </person
阅读全文
摘要:方式一:xml中<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" tools:context=".MainActivity" > <TextV
阅读全文
摘要:为什么安卓在各种各样语言的机器上能够使用,这与它的国际化是不可划分的。如果没有国际化这个功能,那么会出现很多很多的问题,出现乱码之类的问题。在安卓中如何实现国际化?在res目录中,如果想要创建values的其他国家的语言,比如中国的话就可以创建一个文件夹,名叫:values-zh这样,当android语言切换到中文的时候就可以显示里面的内容,例如下面的两个xml文件分别在values-zh中和values中在values中<?xml version="1.0" encoding="utf-8"?><resources> <s
阅读全文
摘要:xml中<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" tools:context=".MainActivity" > <ToggleBut
阅读全文
摘要:xml<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_p
阅读全文
摘要:创建三个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" >
阅读全文
摘要:<?xml version="1.0" encoding="utf-8"?><HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="
阅读全文
摘要:项目需求:list中添加button属性,会使得后面listview不能点击,以下:<LinearLayout 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" tools:context=".M
阅读全文
摘要:xml中<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" tools:context=".MainActivity" > <TextView
阅读全文
摘要:<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" tools:context=".MainActivity" > <ListView andr
阅读全文
摘要:主界面无需太大的修改,设置一些需要的属性,就行了。<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" tools:context=".MainActivity&quo
阅读全文
摘要:DOM= Document Object Model,文档对象模型,DOM可以以一种独立于平台和语言的方式访问和修改一个文档的内容和结构。换句话说,这是表示和处理一个HTML或XML文档的常用方法。节点根据 DOM,HTML 文档中的每个成分都是一个节点。DOM 是这样规定的:整个文档是一个文档节点每个 HTML 标签是一个元素节点包含在 HTML 元素中的文本是文本节点每一个 HTML 属性是一个属性节点注释属于注释节点xml添加一个listview<RelativeLayout xmlns:android="http://schemas.android.com/apk/re
阅读全文
摘要:在主页中显示图片,然后点击向上翻或者向下翻能够实现图片的切换xml中两个button组件,还有一个ImageSwitcher组件<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"
阅读全文
摘要:项目需求:通过点击按钮,显示出来一个对话框,选择其中一个选项之后出来一个进度对话框,一段时间之后自动消失。xml文件中<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" too
阅读全文
摘要:AlertDialog应用2xml中添加一个按钮就可以<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" tools:context=".MainActivity&q
阅读全文
摘要:AlertDialog对话框应用一项目需求:在主页面上显示一个button,点击button,跳出一个对话框,里面有图片,文字还有按钮可以选择;xml中添加一个button<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=&
阅读全文
摘要:一、基础1、说明:创建数据库CREATE DATABASE database-name2、说明:删除数据库drop database dbname3、说明:备份sql server---创建 备份数据的deviceUSE masterEXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'---开始 备份BACKUP DATABASE pubs TO testBack4、说明:创建新表create table tabname(col1 type1 [not n
阅读全文
摘要:集合在使用java的过程,会遇到各种各样的集合,所有的集合都实现了Collection接口list 中有 vector、ArrayList、LinkedList 。 set中HashSet,LinkedHashSet,SortedSet,TreeSetVector:基于Array的list,其实就是封装了Array所不具备的一些功能方便使用。Vector是同步(Synchronized)是线程安全的,arraylist的方法不是ArrayList:基于Array的链表,它不是同步的,在性能上臂Vector优越,LinkedList:不是基于Array的,每一个节点都包含两方便的内容:1.节点本
阅读全文
摘要:android中的数据库只有唯一的SQLite,这样便于操作,该数据库是android自带的数据库,用户无需向j2ee那样,没做一个东西要添加一个jar文件,多么的麻烦。一、数据库的创建package com.will.db;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteOpenHelper;public class DBConn extends SQLiteOpenHelper{ public DBConn...
阅读全文
摘要:单选跟多选的差别在于其中一个元素的不同而已,先看以下的代码:xml<LinearLayout 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:orientation="verti
阅读全文
摘要:通过ListView实现组件单选,并能够对其中的值进行读取的操作。以下是具体的代码: main xml代码:<LinearLayout 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:or
阅读全文
摘要:通过java代码中定义Toast函数可以达到跟在xml文件中定义一样的效果,具体实现如下:package com.will.test;import android.app.Activity;import android.os.Bundle;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.Toast;public class MainActivity extends Activity{ @Override protected void onCreate(B...
阅读全文
摘要:通过直接继承listActivity可以达到listview的效果xml无须做什么修改,只要在Activity文件中修改就可以以下是java代码:package com.example.listactivity;import android.app.ListActivity;import android.os.Bundle;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.BaseAdapter;import androi
阅读全文
摘要:java当中的系列化问题将对象以数据的形式存储到文件中,这个过程叫做系列化。从文件中加载一个对象,叫做反系列化。序列化 必须实现serializable接口,class A implements serializable{ public int a ; public A(int x) {this. a = a;}public void show(){ System.out.println(a)}}main方法中系列化A temp = new A();FileOutputStream fos = new FileOutputStream("d:\\a.txt");Object
阅读全文
摘要:向上转型可以理解为子类转成父类型的;例如:class A{}class B extends A{}A a = new B()这样就是向上类型转换,这个过程是自动进行的,不必程序员去特意的执行。通俗来讲,可以这么理解: Shape s = new Circle();通过父类的引用来使用子类的对象;B b = new B();A a = b;a.play();为什么父类的对象可以引用子类对象:自动实现向上转型,父类的引用可以使用子类中的方法a.play()执行的是父类还是子类的方法?、是执行子类的方法,根据a引用所指向的对来来判断是父类的方法还是子类的方法。不能将子类引用指向父类对象,B b =
阅读全文
摘要:上面所述的adapter只不过是通过观看源代码的形式,将其实现出来,用法还不如它原来的两个类,arrayAdapter和simpleAdapter好用,通过以下的修改可以发现,有了很大的改观,xml文件中和自己创建的xml文件没有进行多大的修改,改的最大的地方就是对于数据的封装,将数据封装到对象中,直接通过对象来传值这样鲜果会更好一点。xml文件<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.andro
阅读全文
摘要:simpleadapter的实现也是比较重要的,通过simpleadapter的源码去重写属于自己的adapter。原始的使用方法,在xml中添加一个listview组件,然后创建一个xml文件,里面放置任意的组件,以下用比较简单的textview来介绍。该方法将数据封装到一个类对象中会跟好处理,以下是xml文件<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
阅读全文
摘要:创建ListView的方式有好多种,其中需要使用到两个方法,一个是ArrayAdapter,另一个是SimpleAdapter。通过查看API可以发现一个很有意思的事情,两个方法都继承自BaseAdapter 实现了ListAdapter接口。既然两个都继承了一样的接口,那么为什么不直接使用baseAdapter,而要使用它的两个继承类?从ArrayAdapter先来看下面的例子:xml文件<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="
阅读全文
摘要:autocompletetextview 自动填充文本框组件该组件使用起来也是比较简单的,只需要定义一个数组,然后将数组放入到arrayAdapter中就可以实现自动填充文本框内容的功能以下是xml代码:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:l
阅读全文
摘要:添加menu的第二种方法,直接在java文件当中添加即可。package com.example.menu_2;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.SubMenu;public class MainActivity extends Activity{ private static final int SETTING_ABOUT = Menu.FIRST; private static final int SETTING_S ...
阅读全文
摘要:<LinearLayout 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:orientation="vertical" tools:context=".Ma
阅读全文
摘要:主xml文件<LinearLayout 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:orientation="vertical" tools:context=&qu
阅读全文
摘要:主xml<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" tools:context=".MainActivity" > <TextView
阅读全文
摘要:主xml中<LinearLayout 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:orientation="vertical" tools:context=&quo
阅读全文
摘要:定义两个xml文件,第一个<LinearLayout 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:orientation="vertical" tools:cont
阅读全文
摘要:<FrameLayout 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" tools:context=".MainActivity" > <ImageView androi
阅读全文
摘要:在drawable中创建一个xml文件<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" > <corners android:radius="10dp"/> <padding android:left="20dp" /> <solid android:color="#ff000
阅读全文
摘要:<LinearLayout 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" tools:context=".MainActivity" android:orientation=&quo
阅读全文
摘要:xml<LinearLayout 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" tools:context=".MainActivity" android:orientation=&
阅读全文
摘要:在drawable-hdpi中创建一个xml用来实现图片的替换工作<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/a1" android:state_pressed="true"/> <item android:draw
阅读全文
摘要:跟六有点不同主xml<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" tools:context=".MainActivity" ><List
阅读全文
摘要:mainactivity.xml<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" tools:context=".MainActivity" >&l
阅读全文
摘要:xml<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" tools:context=".MainActivity" ><ListView an
阅读全文
摘要:mainactivity.xml<LinearLayout 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" tools:context=".MainActivity" > <
阅读全文
摘要:<LinearLayout 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" tools:context=".MainActivity" > <ListView androi
阅读全文
摘要:主xml中<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/listview1" android:layout_width="match_parent" android:layout_
阅读全文
摘要:第一种listviewxml文件中<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/listview1" android:entries="@array/info" android:l
阅读全文
摘要:事件监听器方式一:匿名内部类,直接在组件上添加监听器;例子如下button.setOnclickListener(new OnClickListener(){ System.out.println("hahahh"); });监听方式二:实现某个监听器的接口,然后在添加该接口的实现类实现监听机制;public class MainActivity extends Activity implements OnClickListener{ protected void onCreate(Bundle savedInstanceState) { ...
阅读全文
摘要:例子一:实现下拉列表在res文件下中的values目录中创建array.xml文件<?xml version="1.0" encoding="utf-8"?><resources> <string-array name="address"> <item>厦门</item> <item>上海</item> <item>浙江</item> <item>江西</item> </string-array&g
阅读全文
摘要:<LinearLayout 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:orientation="vertical" tools:context=".Ma
阅读全文
摘要:<LinearLayout 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" tools:context=".MainActivity" > <RadioGroup andr
阅读全文
摘要:<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" tools:context=".MainActivity" ><!-- 相对布局 -->
阅读全文
摘要:继续第一天的内容,接下来介绍第三个组件: checkBox<LinearLayout 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" tools:context=".MainActivity&q
阅读全文
摘要:一、Android开发环境和开发工具搭建 1、到http://eclipse.org/下载android开发需要的开发工具; 2、到http://www.oracle.com/technetwork/java/javase/downloads/index.html下载jdk 3、配置jdk属性,打开我的电脑属性==》高级系统设置==》设置环境变形==》在Administration的用户变量里面添加一个“path=C:\Program Files\Java\jdk1.7.0_09\bin”里面的值是jdk安装目录; 4、打开IDE之后,找到,点击下载的那个,进入到画面,选中需要下载的a...
阅读全文

浙公网安备 33010602011771号