Android 常用代码】的更多相关文章

[Android]调用字符串资源的几种方法   字符串资源的定义 文件路径:res/values/strings.xml 字符串资源定义示例: <?xml version="1.0" encoding="utf-8"?> <resources>     <string name="hello">Hello!</string> </resources> 字符串资源的调用  在 Layout…
这篇文章主要记录一些常用的一些代码段,方便以后查阅,不断更新中. 1:调用浏览器,载入某网址 1 2 3 Uri uri = Uri.parse("http://www.android-study.com"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); 2:Broadcast接收系统广播的intent监控应用程序包的安装.删除 1 2 3 4 5 6 7 8 9 10 11 12 13 14…
1.图片旋转 Bitmap bitmapOrg = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.moon); Matrix matrix = new Matrix(); matrix.postRotate(-90);//旋转的角度 Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, bitmapOrg.getWidth(),…
1. dp px 相互转换---------------public class DensityUtil { /** * 根据手机的分辨率从 dip 的单位 转成为 px(像素) */ public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * sc…
1.单元测试 然而可以直接建立单元测试 <uses-library android:name="android.test.runner"/> 放在application里 <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.pccw" android:label="aaa&qu…
这篇文章主要介绍了Android实用的代码片段 常用代码总结,需要的朋友可以参考下     1:查看是否有存储卡插入 复制代码 代码如下: String status=Environment.getExternalStorageState();if(status.equals(Enviroment.MEDIA_MOUNTED)){ 说明有SD卡插入} 2:让某个Activity透明 OnCreate中不设Layout this.setTheme(R.style.Theme_Transparent…
//36个Android开发常用代码片段 //拨打电话 public static void call(Context context, String phoneNumber) { context.startActivity( new Intent(Intent.ACTION_CALL, Uri.parse( "tel:" + phoneNumber))); } //跳转至拨号界面 public static void callDial(Context context, String…
Android 常用的开发工具记录.其中包括AndroidStudio(IDEA)插件.Mac 上好用的软件以及国内知名Android开发者博客等. Android Studio 插件 codota 插件,提供高质量的Android代码片段搜索,官方网站codota官网 Android 网站 Android Developer Androuid 官网,不解释. AndroidDevTool 国人维护的Android开发工具的整理. Android Arsenal 各种各样的Android开源库的…
关于联系人的一些URI: 管理联系人的Uri: ContactsContract.Contacts.CONTENT_URI 管理联系人的电话的Uri: ContactsContract.CommonDataKinds.Phone.CONTENT_URI 管理联系人的Email的Uri: ContactsContract.CommonDataKinds.Email.CONTENT_URI (注:Contacts有两个表,分别是rawContact和Data, rawContact记录了用户的id和…
在<Android 常用数据适配器ArrayAdapter>中介绍了ArrayAdapter数据适配器.但是存在一个缺陷,那就是条目的图标都固定相同,要显示每个条目的图标都不相同,那么使用SimpleAdapter 新建项目后,在layout文件夹下新建list_item.xml文件,接着编辑布局,代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro…