随笔分类 - Android基础
摘要:1. res下的资源类型 目录资源类型 animator/ 用于定义属性动画的 XML 文件。 anim/ 用于定义渐变动画的 XML 文件。(属性动画也可保存在此目录中,但为了区分这两种类型,属性动画首选 animator/ 目录。) color/ 用于定义颜色状态列表的 XML 文件。请参阅颜色
阅读全文
摘要:转载说明:原贴地址:http://blog.csdn.net/a_running_wolf/article/details/50480386 设置Activity隐藏标题栏、设置Activity全屏显示在我们开发中会经常用到,毕竟手机屏幕大小有限,有时候是为了显示更多的信息而舍弃一些不必要的界面开支
阅读全文
摘要:一、Activity界面的划分 简单说明一下(上图Activity采用默认Style,状态栏和标题栏都会显示):最大的草绿色区域是屏幕界面,红色次大区域我们称之为“应用程序界面区域”,最小紫色的区域我们称之为“View绘制区域”;屏幕顶端、应用界面区之外的那部分显示手机电池网络运营商信息的为“状态栏
阅读全文
摘要:android本事是支持的,很简单 就直接上代码了 1 @Override 2 public boolean onTouchEvent(MotionEvent event) { 3 4 switch (event.getAction()&MotionEvent.ACTION_MASK) { 5 case MotionEvent.ACTION_DOWN: 6 Log.e(TAG, "按下了"); 7 break; 8 case Motion...
阅读全文
摘要:比较简单就直接上代码了 1 package cn.itcast.mobilesafe; 2 3 import android.app.Activity; 4 import android.content.SharedPreferences; 5 import android.content.SharedPreferences.Editor; 6 import android.os.Bundle; 7 import android.os.Environment; 8 import android.util.Log; 9 import android.view.Display;...
阅读全文
摘要:数据缓存的两种方法:1.数据缓存到/data/data目录(ROM) 数据缓存到手机的sd卡上特殊的业务场景,不允许把缓存数据存到手机的rom或者sd卡上2.把资源文件缓存到内存(RAM)里面,保证了数据的安全性,并且不会占用、多用的外存储空间1 private Map<String,Bitmap> bitmapCache;2 bitmapCache=new HashMap<String,Bitmap>();每一次显示图片的时候,首先判断map缓存集合里面是否存在缓存的图片对象1 OutOfMemoryException();软引用:特殊的引用类型,当java虚拟机内存
阅读全文
摘要:Perferenceactivity系统组建可以实现系统设置的窗体,同时省去了我们自己去写配置文件这里面类型很多 下面上代码 自己看效果 自己看下代码就可以懂 很简单首先在res中创建一个文件夹xml,里面建立一个文件setting.xml代表perferenceactivity的关联文件setting.xml 1 <?xml version="1.0" encoding="utf-8"?> 2 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/re
阅读全文
摘要:1.自定义一个类(MaApp)继承Application2.在清单文件中的Application选项菜单对应的name属性中添加MyApp3.重写application中的onCreate方法4.自定义一个类(MyCrashHandler) 实现UncaughtExceptionHandler实现其中的uncaughtException方法5.将MyCrashHandler 采用单例设计模式 加入同步代码块6.在MyApp类中的主线程把这个异常捕获设置进去1 Thread.currentThread().setUncaughtExceptionHandler(MyCrashHandler.ge
阅读全文
摘要:使用的是 net.htmlparesr.jericho.Source;包中的Source,需要导入jaricho-html-3.1.jar的外部jar包一下为用这个包解析豆瓣网站的验证码的代码 1 URL url = new URL("http://www.douban.com/accounts/login"); 2 URLConnection conn = url.openConnection(); 3 //得到服务器返回的html连接 转化成的html的对象 4 Source source = new Source(conn...
阅读全文
摘要:1.布局的背景可以引入一个layout-list.xml代表设置变换的图片,布局上面 中间 结束的颜色不同 1 <?xml version="1.0" encoding="utf-8"?> 2 <layer-list 3 xmlns:android="http://schemas.android.com/apk/res/android"> 4 <item> 5 <shape> 6 <gradient 7 android:startColor="#ffa6a6a6"
阅读全文
摘要:动画类型Android的animation由四种类型组成Android动画模式Animation主要有两种动画模式:一种是tweened animation(渐变动画)XML中JavaCodealphaAlphaAnimationscaleScaleAnimation一种是frame by frame(画面转换动画)XML中JavaCodetranslateTranslateAnimationrotateRotateAnimation如何在XML文件中定义动画① 打开Eclipse,新建Android工程② 在res目录中新建anim文件夹③ 在anim目录中新建一个myanim.xml(注意
阅读全文
摘要:其中在android的文档中有关于这方面的介绍 具体为 Dev Guide 下的 User iNTERFACE 下的Notifications其中主要分3种:Toast Notification (Toast就不用说了 大家都知道) 然后是Status Bar Notification(通知栏消息)以及Dialog Notification 这里主要介绍的通知栏一共4个步骤 在文档中都有说明 下面就直接上代码了 具体的自己看文档吧代码包含直接发送一个通知,以及自定义notification两个布局文件mian.xml 1 <?xml version="1.0" enc
阅读全文
摘要:layout文件 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" 5 android:orientation="vertical"
阅读全文
摘要:layout文件item.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="wrap_content" 5 android:orientation="hor
阅读全文
摘要:代码在Spinner里面,里面的layout里有一个AutoCompleteTextView就是这个还可以使用MultiAutoCompleteTextView控件来完成连续输入的功能,也就是说,当输入完一个字符串后,在该字符串后面输入一个逗号(,),在逗号前后可以有任意多个空格,然后再输入一个字符串,仍然会显示自动提示列表,使用MultiAutoCompleteTextView时,需要为它的setTokenizer方法指定MultiAutoCompleteTextView.CommaTokenizer类对象实例,该对象表示采用逗号作为输入多个字符串的分隔符
阅读全文
摘要:layout 1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" 5 android:orientation="vertical"
阅读全文
摘要:首先在res下创建一个anim文件,在文件下创建一个.xml文件类型为animation-list 1 <?xml version="1.0" encoding="utf-8"?> 2 <animation-list xmlns:android="http://schemas.android.com/apk/res/android" 3 android:oneshot="false" > 4 5 <item 6 android:drawable="@drawable/girl
阅读全文
摘要:main.xml,对于代码创建动画效果在image 及手势识别的日志里 1 <?xml version="1.0" encoding="utf-8"?> 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="fill_parent" > 5 6 <
阅读全文