
Android知识点
homebei2
这个作者很懒,什么都没留下…
展开
-
更改Android模拟器中的hosts文件
<br />下载 android 模拟器后解压得到 android-sdk-linux_x86 文件夹<br />进入到android-sdk-linux_x86/tools/<br />执行 ./android 创建一个test的虚拟手机<br />启动虚拟手机并更改分区大小为128M<br />./emulator -avd test -partition-size 128<br />新打开一个终端在当前目录执行<br />./adb pull /system/etc/hosts /home/jec原创 2010-11-30 17:21:00 · 6168 阅读 · 2 评论 -
android 下修改 hosts文件 及 out of memory的解决
Configure hosts File in AndroidAlright, today I would like to work a sample web site and browse it not only from my Android Emulator but also from my Android G1 device. Since I did not make the web site public yet, I need to play with "hosts" file转载 2010-12-02 14:39:00 · 1101 阅读 · 0 评论 -
Android TextView Justify Text TextView自适应文本
4down votefavoriteHey,How do you get the text of a TextView to be Justified (with text flush on the left- and right- hand sides)? I found a possible solution here, but it does not work (even if you change vertical-center to center_vertical, etc).Cheers,P转载 2010-12-04 12:04:00 · 1653 阅读 · 0 评论 -
activity横竖屏翻转不重载
<br />可以给每个activity加上android:configChanges="keyboardHidden|orientation"属性,就不会重启activity.而是去调用onConfigurationChanged(Configuration newConfig). 这样就可以在这个方法里调整显示方式.<br />比如<br />Java代码 <br />if(newConfig.orientation==Configuration.ORIENTATION_LANDSCA转载 2010-10-15 10:01:00 · 269 阅读 · 0 评论 -
Android版本检测/自动更新
package com.hiyo.game.pdk.tool; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import android.app.Activity; import android.app.AlertDialog; import androi转载 2010-10-15 10:03:00 · 467 阅读 · 2 评论 -
android布局
<br />1、帧布局 FrameLayout:是最简单的一个布局对象。在他里面的的所有显示对象爱你过都将固定在屏幕的左上角,不能指定位置,但允许有多个显示对象,只是后一个会直接覆盖在前一个之上显示,会把前面的组件部分或全部挡住。下图的例子里,FrameLayout中放了3个ImageView组件,第一个是蓝色的,第二个是绿色的,第三个是树状图(透明的 png格式)。ImageView就相当于Html中的img标签,接下来会讲到这个组件。下面看一个FrameLayout的例子:<?xml ver转载 2010-10-15 10:18:00 · 266 阅读 · 0 评论 -
android listview onitemclick
<br />在Android中ListView的使用较为复杂一点,也就是配置其Adapter,Adapter有几种,有ArrayAdapter,SimpleAdapter等,首先要生成一个ListView(当然可以使用ListActivity,此Activity整合了ListView)然后用Adapter来设定ListView的显示数据及布局方式,然后再来响应OnItemClick 事件,或者在ListActivity改写onListItemClick 响应事件函数。看如下代码演示了使用Li转载 2010-10-15 10:21:00 · 1203 阅读 · 0 评论 -
Android通过Intent发送电子邮件含附件
<br />如何在Android系统中发送带附件的电子邮件呢? 其实通过Intent可以很方便的发送Email,只需要短短10行代码就可以处理,这里Android开发网就以在sdcard上的android123.cwj文件为例,通过Intent来发送电子邮件。完整代码如下 <br />File file = new File("/sdcard/android123.cwj"); //附件文件地址<br /> Intent intent = new Intent(Intent.ACTION_SEN转载 2010-10-15 10:22:00 · 641 阅读 · 0 评论 -
android 滑动加载数据
<br />package com.ScrollListView;<br /><br />import android.app.ListActivity;<br />import android.os.Bundle;<br />import android.view.Gravity;<br />import android.view.View;<br />import android.view.ViewGroup;<br />import android.widget.AbsListView;<br />i转载 2010-10-15 10:26:00 · 294 阅读 · 0 评论 -
Android应用开发中的风格和主题(style,themes)
<br />当你设计你的程序的时候,你可以用风格和主题来统一格式化各种屏幕和UI元素。风格是一个包含一种或者多种格式化属性的集合,你可以将其用为一个单位用在布局XML单个元素当中。比如,你可以定义一种风格来定义文本的字号大小和颜色,然后将其用在View元素的一个特定的实例。主题是一个包含一种或者多种格式化属性的集合,你可以将其为一个单位用在应用中所有的Activity当中或者应用中的某个Activity当 中。比如,你可以定义一个主题,它为window frame和panel 的前景和背景定义了转载 2010-10-15 10:32:00 · 178 阅读 · 0 评论 -
Android TextView(EditView)文字底部或者中间 加横线
promotionLinkText = (TextView) this .findViewById(R.id. text_promotion_link );中间加横线 promotionLinkText .getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );底部加横线:promotionLinkText .getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );转载 2010-10-15 10:16:00 · 433 阅读 · 0 评论 -
使用scrollview不让键盘覆盖编辑框
<br />我在Android一个界面有一个编辑的文本框,当文本框获得焦点的时候就会弹出一个模拟键盘,而这个键盘把文本框给盖住了!!!使文本框编辑不方便,也看不到编辑的效果,有什么方法不让模拟键盘遮住文本编辑框了吗,到网上问问各位大侠和查了些资料具体的解决方法如下,主要使用的是:ScrollView <br /><br />xml文件: <br /><?xml version="1.0" encoding="utf-8"?> <br /><LinearLayout xmlns:androi转载 2010-10-15 10:20:00 · 341 阅读 · 0 评论 -
带输入框(EditText)的AlertDialog
<br />一、Main Class:<br />public void search() {<br /> Builder dialog = new AlertDialog.Builder(this);<br /> LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);<br /> LinearLayout layout = (LinearLa原创 2010-10-15 10:32:00 · 386 阅读 · 0 评论 -
android.view.WindowLeaked
<br />android.view.WindowLeaked一般会发生在Activity 与Dialog的显示。Activity 中create 一个Dialog,若你先关闭Dialog再关闭Activity就是正常的,若你先关闭Activity再关闭Dialog就会报错这个 android.view.WindowLeaked错误了。我分析这个原因是:Dialog是基于Activity而创建的:new ProgressDialog(this);this 就是Activity。 Activtity先fi原创 2010-10-16 14:35:00 · 959 阅读 · 0 评论 -
ApIDemo Transition3d
<br />package com.example.android.apis.animation;import com.example.android.apis.R;import android.app.Activity;import android.os.Bundle;import android.widget.ListView;import android.widget.ArrayAdapter;import android.widget.AdapterView;import原创 2010-10-22 11:27:00 · 413 阅读 · 2 评论 -
Android的animation
<br />import android.app.Activity; <br />import android.os.Bundle; <br />import android.view.View; <br />import android.view.View.OnClickListener; <br />import android.view.animation.AccelerateDecelerateInterpolator; <br />import android.view.anima转载 2010-10-22 11:45:00 · 446 阅读 · 0 评论 -
自定义View
<br />/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *原创 2010-10-22 16:23:00 · 204 阅读 · 0 评论 -
APIDeMO 时间Wight设置
<br /><br />/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at原创 2010-10-22 16:30:00 · 235 阅读 · 0 评论 -
Intent入门指南
<br />一、什么是Intent:<br />在一个Android应用中,Intent是对执行某个操作的一个抽象描述,Intent 负责提供组件之间相互调用的相关信息传递,实现调用者和被调用者之间的解耦。<br />二、Intent的属性:<br />Intent是对执行某个操作的一个抽象描述,其描述的内容包括,对执行动作Action的描述、对操作数据的描述、还有4种附加属性的描述。分别介绍如下:<br /><br /> Action ,对执行动作的描述,是个字符串,是对所将执行的动作的描述,在I转载 2010-10-23 10:57:00 · 192 阅读 · 0 评论 -
AutoCompleteTextView、ContentResolver、Contacts
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *原创 2010-10-22 15:28:00 · 773 阅读 · 0 评论 -
APIDEMO TABLELAYOUT
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *原创 2010-10-23 17:59:00 · 190 阅读 · 0 评论 -
android线性布局参数详解
线性布局中,有4个及其重要的参数,直接决定元素的布局和位置,这四个参数是android:layout_gravity (是本元素相对于父元素的重力方向)android:gravity (是本元素所有子元素的重力方向)android:orientation (线性布局以列或行来显示内部子元素)android:layout_weight(线性布局内子元素对未占用空间【水平或垂直】分配权重值,其值越小,权重越大。转载 2010-10-22 15:00:00 · 240 阅读 · 0 评论 -
星星CheckBox按钮
style="?android:attr/starStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/controls_1_star" />星星CheckBox按钮,android自定义样式原创 2010-10-22 16:01:00 · 353 阅读 · 0 评论 -
View 布局
<br />常用Layout介绍:FrameLayout, LinearLayout<br />点此下载:Android学习指南第五讲源代码<br />一、什么是View<br />我们上节课说,Activity是Android程序的显示层,每一个显示窗口都是一个Activity;可是Activity本身无法显示在屏幕上,我们可以把它理解成是一个抽象层,一个壳子;就譬如一个JSP页面,它本身并没有显示出来任何东西,负责显示的是他生成的HTML标签。那么Android里谁才是真正显示出来的部分?-转载 2010-10-22 17:31:00 · 585 阅读 · 2 评论 -
APIDEMO IMAGESWITCHER
/*<br /> * Copyright (C) 2007 The Android Open Source Project<br /> *<br /> * Licensed under the Apache License, Version 2.0 (the "License");<br /> * you may not use this file except in compliance with the License.<br /> * You may obt转载 2010-10-23 16:50:00 · 241 阅读 · 0 评论 -
Android SDK自带教程之BluetoothChat
<br />MainFest xml<br /><?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the Lice原创 2010-12-15 16:37:00 · 1839 阅读 · 0 评论 -
ConnectivityManager 连接管理
<br />public static boolean isWiFiActive(Context inContext) {<br /> Context context = inContext.getApplicationContext();<br /> ConnectivityManager connectivity = (ConnectivityManager) context<br /> .getSystemService(Conte原创 2010-12-14 09:38:00 · 468 阅读 · 0 评论 -
GestureListener
<br />class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) r原创 2010-12-14 11:22:00 · 678 阅读 · 0 评论 -
Android系列教程之七:EditText使用详解-包含很多教程上看不到的功能演示
一:新建HelloEditText工程<br /> <br />新建一个Hello world详细步骤可以参见<br />Android教程之三:第一个Android应用,HelloWorld<br />创建设置如下:Project name:HelloEditTextBuild Target :android 2.2Application name:HelloEditTextPackage name:com.flysnowcreate Activity:HelloEditTextmin SDK 8<br转载 2010-12-15 15:58:00 · 3453 阅读 · 3 评论 -
Android SDK 自带项目GestureBuilderActivity
<br />需要android.permission.WRITE_EXTERNAL_STORAGE权限<br /><?xml version="1.0" encoding="UTF-8"?><!-- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except原创 2010-12-16 16:17:00 · 938 阅读 · 0 评论 -
Android ANR介绍与避免
<br />很多初入Android开发的网友可能发现ANR的字样,到底Android ANR是什么呢? 其实ANR就是Application Not Responding的全称,当某个应用处于长期假死状态时Android系统会弹出一个窗口上面写道,XXX is not responding给出两个按钮一个为force close一个为wait。<br /> 可能触发ANR的情况<br /> 1. 长时间的I/O处理,比如读写大文件,网络访问时造成的阻塞。<br /> 2. 执行耗时的运算原创 2010-10-26 21:02:00 · 676 阅读 · 0 评论 -
Android屏幕截图之View方法
<br /> 很多网友可能发现Android并没有提供屏幕截图ScreenShot的方法,了解Linux的网友可能知道直接读取/dev/graphics/fb0即可来实现framebuffer,当然了对于自己的View实现一些绘图或子类化的技术时可以不用系统级这样的方法,我们可以通过<br />view.setDrawingCacheEnabled(true); //其中View是你需要截图的的View <br />Bitmap bm = view.getDrawingCache();<br /原创 2010-10-26 21:07:00 · 902 阅读 · 0 评论 -
为有源头话水来——使用SQLite、ContentProvider与Preferences处【3】
9.4 使用Preferences 存储应用程序数据<br />Preferences是一种轻量级的数据存储机制,它将一些简单数据类型的数据,包括boolean类型、int类型、float类型、long类型以及String类型的数据,以键值对的形式存储在应用程序的私有1<br />Preferences目录(/data/data/<包名>/shared_prefs/)中。这种Preferences机制广泛应用于存储<br />应用程序中的配置信息。<br />在Android平台上,只需要用一个原创 2010-10-28 11:28:00 · 791 阅读 · 0 评论 -
CubeWallpaperSet动态壁纸探究
随着三星Oscar的上市,流畅的操作,华丽的界面,OPhone 2.0的不俗表现不禁让人眼前一亮。作为OPhone 2.0一个新特性,动态壁纸(Live Wallpapers)为用户带来了更炫体验。本文主要通过一个完整的时间壁纸(TimeWall)为大家介绍如何开发 Live Wallpapers。还没开发环境?赶紧去下载OPhone SDK 2.0吧!1、 Live Wallpapers是什么? 在oscar上有一个动态壁纸叫“天空草地”,用过一段时间,可以发现,随着时原创 2010-12-16 11:31:00 · 3128 阅读 · 1 评论 -
Android开发之旅: Intents和Intent Filters(理论部分)
Android开发之旅: Intents和Intent Filters(理论部分)2010-07-20 20:07 by 吴秦, 2974 visits, 网摘, 收藏, 编辑引言大部分移动设备平台上的应用程序都运行在他们自己的沙盒中。他们彼此之间互相隔离,并且严格限制应用程序与硬件和原始组件之间的交互。 我们知道交流是多么的重要,作为一个孤岛没有交流的东西,一定毫无意义!Android应用程序也是一个沙盒,但是他们能够使用Intent、 Broadcast Receivers、Adapte转载 2010-12-16 16:58:00 · 425 阅读 · 0 评论 -
JetBoy游戏深入解析(下)——核心代码分析
<br />有个前面2篇(框架分析、JetPlayer类解析)的介绍,相信大家都迫不及待的想知道JetBoyThread这个核心类到底是如何运行的,下面我们就逐步为大家解析。首先,分析这个类的状态图,如下所示<br /><br />这张图就是我们整个程序的循环周期:PLAY——RUNNING——LOSE。根据这张图,我们逐步细化,这里我们重点介绍RUNNING,其他2种状态比较简单,这里就不再说明了。然后,START_RUNNING 状态逐步细化,详细说明<br />START_RUNNING原创 2010-12-18 11:24:00 · 842 阅读 · 0 评论 -
控制Android LED灯颜色代码
<br /> 很多Android手机上都配有LED灯,比如HTC的手机在充电、新来短信等时候都会有响应的指示,其实很简单的这都是NotificationManager的一些参数而已,下面Android123给大家说下如何通过代码控制LED灯的闪烁,因为有些机型没有LED灯或颜色种类较少,发布时需要真机观察。<br /> final int ID_LED=19871103; <br /> NotificationManager nm=(Notificatio原创 2010-10-26 21:03:00 · 592 阅读 · 0 评论 -
Android Widget开发模板
Android上的Widget使用了Java语言开发比W3C的Widget运行效率提高了不少,可以做更多的事情调用系统的API,除了UI上的限制外,我们可以考虑帮助系统完善一些appWidget,Android123给出大家一个开发Widget的模板。public class cwjWidget extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManage转载 2010-10-26 21:09:00 · 231 阅读 · 0 评论 -
为有源头话水来——使用SQLite、ContentProvider与Preferences【2】
9.3 ContentProvider<br />当数据需要在应用程序间共享时,我们就可以利用ContentProvider为数据定义一个URI。之后<br />其他应用程序对数据进行查询或者修改时,只需要从当前上下文对象获得一个ContentResolver<br />(内容解析器)传入相应的URI就可以了。本节中将以前面创建的code.db数据库为例,向读者介<br />绍如何定义一个ContentProvider,以及如何在其他程序中使用ContentResolver访问URI所指定<br原创 2010-10-28 11:21:00 · 1194 阅读 · 1 评论 -
Activity类的runOnUiThread方法
<br /> 如果你对于Android的Thread+Handler方式感觉繁琐,不妨试试Activity提供的另外一种简单的方法runOnUiThread,runOnUiThread可以帮助你在线程中执行UI更新操作,我们只需要在线程中写上类似<br /> android123.this. runOnUiThread(new Runnable() { <br /> @Override <br /> pub原创 2010-10-26 20:58:00 · 382 阅读 · 0 评论