1、 安卓图片自适应

android从1.6和更高,Google为了方便开发者对于各种分辨率机型的移植而增加了自动适配的功能 
<supports-screens 
android:largeScreens="true" 
android:normalScreens="true" 
android:smallScreens="true" 
android:anyDensity="true"/>

2、 /*获取屏幕像素和屏幕密度*/

DisplayMetrics metrics=new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(metrics);

int width=metrics.widthPixels;

int height=metrics.heightPixels;

float density=metrics.density;

int densityDpi=metrics.densityDpi;

3、  Android2.2中match_parent和fill_parent是一个意思 .两个参数意思一样,match_parent更贴切,于是从2.2开始两个词都可以用。那么如果考虑低版本的使用情况你就需要用fill_parent了

4、  读取电话薄

AndroidManifest.xml

<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>

java文件:

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//
setContentView(R.layout.activity_contacts);

TextView tv = new TextView(this);

// TextView tv =
(TextView) findViewById(R.id.textViewC1);

String string = "联系人如下:\n";

try {

// 得到ContentResolver对象

ContentResolver contentResolver = getContentResolver();

// 取得电话本中开始一项的光标

Cursor cursor = contentResolver.query(

ContactsContract.Contacts.CONTENT_URI, null, null, null,

null);

// 向下移动光标

while (cursor.moveToNext()) {

// 取得联系人名字

int nameFieldColumnIndex = cursor

.getColumnIndex(PhoneLookup.DISPLAY_NAME);

String contract = cursor.getString(nameFieldColumnIndex);

// 取得电话号码

int
numberFieldColumnIndex = cursor

.getColumnIndex(PhoneLookup.NUMBER); String number =

cursor.getString(numberFieldColumnIndex);

string += contract + "\n";

}

cursor.close();

tv.setText(string);

setContentView(tv);

} catch (Exception e) {

e.printStackTrace();

Log.i(TAG, e.toString());

}

}

5、
窗口切换public void onCreate(Bundle
savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_01);

Log.i(TAG, "onCreate");

Button button1 = (Button) findViewById(R.id.button11);

/* 监听button的事件信息 */

button1.setOnClickListener(new Button.OnClickListener() {

public void onClick(View v) {

// 新建一个Intent对象

Intent intent = new Intent();

// 指定Intent要启动的类

intent.setClass(Activity01.this, Activity02.class);

// 启动一个新的Activity

startActivity(intent);

// 关闭当前的Activity

Activity01.this.finish();

}

});

}

6、  android.intent.action.MAIN决定应用程序最先启动的Activity ,android.intent.category.LAUNCHER决定应用程序是否显示在程序列表里。Main和LAUNCHER同时设定才有意义

Android常用知识笔记的更多相关文章

  1. 打造自己的Android常用知识体系

    前言 Android常用知识体系是什么鬼?所谓常用知识体系,就是指对项目中重复使用率较高的功能点进行梳理.注意哦,不是Android知识体系. 古语道:学而不思则罔,思而不学则殆.如果将做项目类比为“ ...

  2. Android基础知识笔记01—框架结构与四大组件

    -----------Andriod 01--------------->>> Andriod系统架构    linux内核与驱动层. 系统运行库层. 应用框架层. 应用层 内核驱动 ...

  3. git常用知识笔记

    学习资料: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 http://codi ...

  4. 阿里内部资料:Android开发核心知识笔记共2100页,58万字,完整版开放下载

    作为一个3-5年的Android工程师,我们经常会遇到这些瓶颈: 1.技术视野窄长期在小型软件公司,外包公司工作,技术视野被限制的太厉害 2.薪资提升难初中级Android岗位薪资上升空间有限,基本上 ...

  5. Android 常用开发工具以及Mac常用软件

    Android 常用的开发工具记录.其中包括AndroidStudio(IDEA)插件.Mac 上好用的软件以及国内知名Android开发者博客等. Android Studio 插件 codota ...

  6. Android群英传笔记——第六章:Android绘图机制与处理技巧

    Android群英传笔记--第六章:Android绘图机制与处理技巧 一直在情调,时间都是可以自己调节的,不然世界上哪有这么多牛X的人 今天就开始读第六章了,算日子也刚好一个月了,一个月就读一半,这效 ...

  7. Android群英传笔记——第五章:Android Scroll分析

    Android群英传笔记--第五章:Android Scroll分析 滑动事件算是Android比较常用的效果了,而且滑动事件他本身也是有许多的知识点,今天,我们就一起来耍耍Scroll吧 一.滑动效 ...

  8. Android群英传笔记——摘要,概述,新的出发点,温故而知新,可以为师矣!

    Android群英传笔记--摘要,概述,新的出发点,温故而知新,可以为师矣! 当工作的越久,就越感到力不从心了,基础和理解才是最重要的,所以买了两本书,医生的<Android群英传>和主席 ...

  9. Windows、Linux、Android常用软件分享

    Windows.Linux.Android常用软件分享 前言 本来没准备写这篇博客,一是没时间,还有其他很多优先级更高的事情要做.二是写这种博客对我自己来说没什么的帮助,以前我就想好了不写教程类,使用 ...

随机推荐

  1. Redis 实现高效不遗漏的事件封装

    虽然Redis有订阅功能,但是订阅功能是实时的,过了这个点,就接收不到消息了. 同时,如果订阅的客户端因为某些特殊原因shutdown了,那也就找不回未处理完整的订阅事件了. 但好在,Redis还有一 ...

  2. Hibernate 抓取策略fetch-1 (select join subselect)

    原文 :http://4045060.blog.51cto.com/4035060/1088025 部分参考:http://www.cnblogs.com/rongxh7/archive/2010/0 ...

  3. IOS开发-UIBarButtonItem系统自带图标总结

    1.这四个返回的是后面的单词. UIBarButtonSystemItemDone UIBarButtonSystemItemCancel UIBarButtonSystemItemEdit UIBa ...

  4. LVS包转发模型和调度算法(转)

    LVS简介 Internet的快速增长使多媒体网络服务器面对的访问数量快速增加,服务器需要具备提供大量并发访问服务的能力,因此对于大负载的服务器来 讲, CPU.I/O处理能力很快会成为瓶颈.由于单台 ...

  5. BOOST的AUTO link机制以及配置

    我们在使用BOOST的时候,如果需要链接一些库,是不用我们手动去链接的,归根结底还是boost的auto_link这个机制,在boost下的auto_link.hpp这个文件夹里面,基本可以看出要根据 ...

  6. JavaScript中Eval()函数的使用

    Eval()常用的几种形式 1.我们预先不知道要执行什么语句,只有当条件和参数给时才知道执行什么语句,这时候eval就派上用场了. function output(a, b) { var tmpa, ...

  7. @synthesize obj = _obj 理解

    在很多代码里可以看到类似得用法: @interface MyClass:NSObject{ MyObjecct *_object; } @property(nonamtic, retain) MyOb ...

  8. c# 甘蔗斗地主1.4存档修改器

           using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...

  9. 值得推荐的C/C++框架和库 (真的很强大)

    值得学习的C语言开源项目 - 1. Webbench Webbench是一个在Linux下使用的非常简单的网站压测工具.它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的 ...

  10. 网页地图map

    <map name="map"> <area shape="rect" coords="75,75,99,99" nohr ...