android
文章平均质量分 76
czjuttsw
Learning, staying up to date, and working on the latest and greatest in languages and APIs is what keeps me excited.
展开
-
AsyncTask实例
最近刚刚接触AsyncTask,了解了执行一个异步任务类的基本过程,然后自己动手做了一个后台下载MP3,前台显示进度的小测试,作为对知识的一次巩固,代码如下:新建工程MyAsyncTask,其目录结构如下:然后修改/res/layout/main.xml,代码如下:<LinearLayout xmlns:android="http://schemas.androi原创 2012-07-03 10:22:06 · 1275 阅读 · 0 评论 -
Android-高德地图-显示气泡框
现在的聊天框大多都是气泡框,气泡框长相可爱,有良好的用户体验。 如何把气泡框应用于地图上呢? 步骤一:首先要定义我们的气泡框布局,也就是所谓的layout。popup.xml:<LinearLayout android:orientation="horizontal" android:id="@+id/LinearLayoutPopup"原创 2013-04-03 17:06:58 · 6486 阅读 · 0 评论 -
Vertu手机决定采用Android系统
Vertu手机决定采用Android系统 英文原文:Vertu Unveils Android Plan 翻译: ImportNew-黄小非智能手机奢侈品牌Vertu的制造商已经决定放弃Windows Phone 8,转而采用Android操作系统,其原因主要是因为微软的手机操作系统“复杂度太高”。最新的Ver原创 2013-04-24 13:43:27 · 2085 阅读 · 0 评论 -
自定义Toast
在Android中,默认的Toast样式很难看。而且,Toast存在一个小小的bug,就是后来的toast必须要等之前的toast消失后才能显现出来,不过有一个解决方案,见http://blog.csdn.net/czjuttsw/article/details/8274276 一般地,我喜欢用toast来打印一些测试信息,虽然更推荐使用LogCat。细心的人可能注意到,原创 2013-04-29 14:39:00 · 5459 阅读 · 0 评论 -
Android 实现简单的即时通信
IM是Instant Message的缩写,意思是即时通信。所谓即时通信,顾名思义,就是一方发送信息给另一方,另一方能够即时收到信息。 我们身边熟知的即时通信莫过于腾讯QQ了。无论从桌面版,还是到移动版,都有即时通信的身影。不过QQ的IM有它们自己内部的通信协议,并且是对外不公开的。这种技术封闭大大阻碍了前沿技术领域的发展。而随着时代的前进,开源(Open source) 这一振原创 2013-04-20 21:24:41 · 8360 阅读 · 1 评论 -
Android如何从服务器获取图片
public static Bitmap getBitmapFromServer(String imagePath) { HttpGet get = new HttpGet(imagePath); HttpClient client = new DefaultHttpClient(); Bitmap pic = null; try { HttpResponse resp原创 2013-05-03 14:05:46 · 6946 阅读 · 2 评论 -
setTranscriptMode失效怎么办
当我们希望列表总是回滚到最下端来展示最新的信息时,在代码端可以使用: listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);在xml文件可以使用属性: android:transcriptMode="alwaysScroll" 如果在某些时候使用上面的方法依然无法实现回滚到最下端的功能时,原创 2013-05-08 22:07:32 · 4022 阅读 · 0 评论 -
Android 仿 WP7 布局
布局文件:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#000000" and原创 2013-05-11 23:06:34 · 1895 阅读 · 0 评论 -
Android 滚动控件 之 省市区
Android没有自带的类似iPhone的滚动控件还好有人实现了Android版本的滚动控件wheelView.http://android-wheel.googlecode.com/svn/trunk由于项目需要实现一个内容为省市区的滚动控件,几番周折,最终效果如下:源代码在此:原创 2013-07-20 18:28:12 · 2021 阅读 · 0 评论 -
android解析plist文件
plist,即property list,是苹果手机软件开发中经常用到的存储文件格式,其实质就是XML文件,但是它遵循一定的格式。比如包含一些指定的元素,如plist,array,string,key等。苹果提供了解析该类文件的机制,可惜在安卓开发工具中却没有提供。经常遇到的情况是,在开发苹果和安卓手机软件的时候,要统一资源文件,这个时候,我们可以采用GitHub中提供的开源android-pli原创 2013-08-01 11:26:34 · 9006 阅读 · 5 评论 -
Android(Animation): 一直转个不停的齿轮
利用RotateAnimation实现齿轮的无限匀速转动:1. Activity的布局文件:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_w原创 2013-11-28 11:06:49 · 4721 阅读 · 0 评论 -
[Android] 对ImageView设置属性scaleType为FIT_START,如何去掉多余空白
当对ImageView设置了属性scaleType为FIT_START时,可以通过调用ImageView的setAdjustViewBounds(true)。即: imageView.setScaleType(ImageView.FIT_START); imageView.setAdjustViewBounds(true);原创 2014-04-06 18:07:06 · 4879 阅读 · 0 评论 -
Android Activity和Fragment的生命周期图
原创 2014-05-16 00:24:27 · 1275 阅读 · 0 评论 -
TabHost tab项单击事件
TabHost 选项发生变化时会触发OnTabChangedListener事件,但是如果当前已经选中第一项,再次单击该项时,OnTabChangedListener不会触发该事件,所以再次单击选中tab项时,想处理页面内容,会比较麻烦,因为没有事件触发 getTabWidget().getChildAt(0).setOnClickListener(new OnClickListener(转载 2014-08-21 00:10:13 · 3559 阅读 · 0 评论 -
利用Android的传感器改变背景颜色
最近许多程序都使用了android机硬件的传感器(Sensor),其中传感器又分为好几种,比如方向,加速计,温度,磁场等,但是不同机型并不保证包括所有类型的传感器。不过大部分机子都包括加速计,下面写一个简单的demo来演示利用加速计改变应用背景颜色。1.Activity:public class MainActivity extends Activity implements原创 2013-02-24 10:26:33 · 1989 阅读 · 0 评论 -
Android和iPhone截屏快捷键
截屏快捷键(Power + Home)其实在手机上截屏非常容易。只要同时按住关机键(Power)和主页键(Home)一会儿,系统就会将当前屏幕作为图片存储在手机相册里。已经在HTC Explorer和iPhone 4S测试过。这个快捷键适用于最新版本的Android和所有iOS设备。原创 2013-01-08 15:08:07 · 1956 阅读 · 0 评论 -
Eclipse集成开发环境如何与android手机连接的一个解决办法
在开发android应用程序时,我们最初都是利用Eclipse上自带的avd来运行自己编写的应用程序。但是这种方法存在一些令人不愉快的缺陷,比如第一次启动AVD都比较慢(一般都在3~5分钟左右)或者在AVD调试程序时没有问题,但是在真机上运行时可能就会出现异常(这种异常如果不借助Logcat根本很难知道错误是什么)所以,其中一种解决办法就是在真机上调试程序,因此我们常常将android原创 2012-09-20 22:27:33 · 5014 阅读 · 2 评论 -
利用GPS定位[android]
这是我在CSDN里发表的第一篇博客。我是在大学期间跟学长一起做项目时开始接触Android的。由于自己有JAVA编程的基础,以及拥有可以测试的Android手机,于是在空闲时间在图书馆阅读android方面的书籍。因为我们的项目是基于定位的,因此免不了要学习定位相关的知识。但是书上讲的内容大多都是理论上的,对于刚刚接触android的新手来说存在很多的困难。于是我求助于CSDN各位大神的博客,原创 2012-07-02 12:18:16 · 2704 阅读 · 0 评论 -
监听SMS消息
转载自:http://www.cnblogs.com/xirihanlin/archive/2009/10/22/1588356.html监听SMS消息当设备接收到一条新的SMS消息时,就会广播一个包含了android.provider.Telephony.SMS_RECEIVED动作的Intent。注意,这个动作是一个字符串值,SDK 1.0不再包含对这个字符串的引用,因此,转载 2012-10-29 14:18:37 · 1343 阅读 · 0 评论 -
Service实例应用之电话录音
我们知道,Android有四大组件,分别是Activity,Content Provider , Broadcast Receiver 和今天我们要用到的Service。我们说Service是看不见摸不着的,是因为它对用户是不可见的,Service作为四大组件之一,它的职责是工作在后台,处理一些比较耗时的操作(如下载,播放媒体文件,检测版本更新和日志输出等)。就像学习Activity组原创 2012-10-29 23:47:11 · 5863 阅读 · 6 评论 -
Android地图开发之Overlay应用(高德)
做过Android地图应用开发的人员都知道,现在流行的地图框架不外乎是Google,百度以及高德地图。对于Google和百度的地图开发,首先需要获得一个API KEY,然后才能被授权开发应用。而高德地图则不用这么麻烦。因此,本篇采用高德地图来开发一个简单的DEMO。在开始之前,需要在高德官网上下载相应的jar开发包,下载地址为:http://api.amap.com/Android原创 2012-11-01 14:08:30 · 7326 阅读 · 0 评论 -
对populate()方法的理解
在开发地图的应用中,我们很多时候需要在地图上绘制一些文本,图标信息(比如当前位置的图标,比如某个区域内肯德基店的所有兴趣点)为了能够在地图上绘制我们需要的信息(比如图片),我们需要知道图层的概念。(就像photoshop里的图层)接下来我们需要利用API接口实现我们的功能(我们这里采用的是高德的API,高德API开发包可自行在官网上下载)高德API提供了一个基类Overlay,用于原创 2012-11-03 01:15:54 · 12101 阅读 · 0 评论 -
细谈Activity生命周期
最近在开发一个小小的应用,由于一个Activity里不仅要创建各种各样的类,而且要在恰当的时机释放掉被占用的资源。由于生命周期方法是被自动调用的因此,有必要了解Activity的生命周期方法的调用时间和顺序。下面是一个简单的测试类,利用android.util.Log的静态方法d(debug),i(info),e(error)等可以在LogCat里输出不同类型的日志信息(不同类原创 2012-11-05 00:09:43 · 13334 阅读 · 2 评论 -
利用smack实现基于XMPP协议的简单通信demo
XMPP+OPENFIRE+SMACK 首先需要安装即时通信服务器,这里使用开源的openfire 下载地址: http://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire_3_7_1.exe 接下来需要下载类库smack,该类库实现了XMPP协议,可以实现该类库的原创 2012-11-08 20:53:38 · 8841 阅读 · 0 评论 -
利用Parcelable在Activity之间传输对象
在Android的不同Activity之间传输数据并不像传输参数那样简单。我们需要做的就是把需要传输的数据绑定到intent对象上。如果我们需要传输的对象是一些简单的Object,比如String类型或者Integer类型,那事情就好做了:String strinParam = "String Parameter";Integer intParam = 5; Intent i = n翻译 2012-11-15 10:44:41 · 11165 阅读 · 3 评论 -
ListView和性能
一谈起ListView,我想大家都不陌生。而且最近该控件特别红,像QQ,人人和新浪客户端里都有它的影子。其实实现ListView非常的简单。我想大家都用过各种各样的控件,比如说一个最简单的TextView,我们都是在布局文件里加入TextView标签,然后在Activity里通过findViewById(int id)方法得到该对象的引用,最后调用TextView类的setText(Cha原创 2012-11-16 23:54:27 · 1734 阅读 · 0 评论 -
自定义View
如果我们想要自定义View,我们可以继承View类,下面给出一个画图例子来讲解如何实现自己的Viewpackage com.example.mycustomview;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android原创 2012-11-18 00:03:56 · 2835 阅读 · 0 评论 -
高德地图-绘制个人历史位置路线
思路:将当前个人位置(经纬度信息)存储到手机数据库(SQLITE)中,然后遍历数据库中的所有位置信息,并绘制到MAP图层上。1.数据库帮助类:package com.example.touchpoint;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import原创 2012-12-08 16:01:06 · 11779 阅读 · 4 评论 -
Android 获取系统自带相机的照片
import android.app.Activity;import android.content.Intent;import android.graphics.Bitmap;import android.graphics.Color;import android.os.Bundle;import android.os.Environment;import android.provi原创 2012-12-09 00:50:31 · 1482 阅读 · 0 评论 -
Android 解决Toast中的一个BUG(转载)
做程序员的,基本一看api就知道,用这个可以取消上一个toast的显示,然后显示下一个,这样就能解决出现的问题。可是在测试的过程中,发现却没有想象中的那么简单,不信可以百度一下,很多很多人发现toast的cancel()方法不起作用。还是不讲具体过程,只讲结果吧。我把toast做成了一个应用类,方便使用,大家可以直接用:public class ToastUtil {原创 2012-12-09 01:36:29 · 4610 阅读 · 2 评论