在Android开发中,资源包括文件或者值,它们和执行应用捆绑,无需在源代码中写死,因此我们可以改变或替换他们,而无需对应用重新编译。了解资源构成参考阅读Android学习笔记(三八):资源resource(上)、XML解析(XmlPullParser),Android学习笔记(三九):资源resource(下)。Strings资源。位于res/values下,可以有一个或多个xml文件。其中最为常见的是strings.xml,对于demo这类小例子,为了方便常全部都放在strings.xml中...
一、简介 二、代码1.xml(1)activity_main.xml 1 <?xml version="1.0" encoding="utf-8"?>2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"3 android:orientation="vertical" android:layout_width="fill_parent"4 android:layout_height="fill_parent">5 6 <Button android:id="@+id/scaleButtonId" android:layout_width="fill_parent"7 android:layout_height="wrap_content...
原始资源android中没有专门提供管理支持的类型文件,都被称为原始资源。例如:声音资源...android原始资源存放位置: 1.res/raw,android SDK会处理该目录下的原始资源,会在R清单中生成唯一索引 2./assets/,该目录下的资源是更彻底的原始资源。android通过AssetManager来管理该目录下的原始资源注意:原始资源通过SDK生成的唯一索引的使用方式同其他资源使用方式一致。EG:R.raw.filename/@raw.filename AssetManager是一个专...
目录(?)[-]EditText Preferencesxml文件设备的存贮文件Ringtone PreferencesEditText Preferencesxml文件在res/xml/中增加edittext.xml文件,如下:<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="packet_name" android:title="Package Name"> <EditTextPreference android:key="package_name_pref" android:title="Set P...
一、layout介绍二、测试linear_layout1.activity_main.xml<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal" ><TextView android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#ff0000"android:text="第一个"...
调用拨号界面拨打电话(不直接打出去) Intent intent1= new Intent(Intent.ACTION_DIAL); intent1.setData(Uri.parse("tel:400-8181800")); startActivity(intent1); Manifest文件里: 设置权限 <uses-permission android:name="android.permission.CALL_PRIVILEGED" /> (报错的话,clean项目,)************************************************************************************************...
/framework/cmds 部分 这部分主要是命令的实现部分。 android 本身是支持一部分linux命令的,并且再次基础上android又添加了一些他自身独有的命令,而这些命令正在存放在/framework/cmds文件夹下面的。 先来看第一个例子: am am 命令,我没能在源码中找到解释am具体的作用的描述文档,我只能根据源码来自己形容他,这个是一个用于开启组件的命令,包括activity 还有 service 。 ok,我的描述结束,接下来看源码: publ...
Android开发中,有时候我们需要对信息进行保存,那么今天就来介绍一下,保存文件到内存,以及SD卡的一些操作,及方法,供参考。 第一种,保存数据到内存中: //java开发中的保存数据的方式 public static boolean saveUserInfo(String username,String password){File file = new File("/data/data/com.ftf.login/info.txt");try {FileOutputStream fos = new FileOutputStream(file);// ftf##123fos.write((username+"##"+passwor...
Activity生命周期Activity的活动状态由android已Activity栈的形式管理,当前活动的Activity位于栈顶。随着不同应用的运行,每个Activity都有可能从活动状态转入非活动状态,从非活动状态转入活动状态。Activity归纳大致会经过4个状态: 1.活动状态:当前Activity位于前台,用户可见,可获得焦点; 2.暂停状态:其他Activity位于前台,该Activity可见,不可获得焦点; 3.停止状态:该Activity不可见,失去焦点; 4.销毁...
在学习Android开发的过程中遇到了不少的问题,所幸的是最终经过上网查询都得到了解决。现在将我在学习Android开发过程中遇到的一些问题及解决的方法整理如下。1.R.java不能实时更新 问题描述:在res文件中新增的变量不能在R.java中实时的显示出来。 解决方法:选择菜单栏的“Project”,勾选“Build Automatically”选项。2.LogCat视窗没有显示 问题描述:在Eclipse的右下方没有显示LogCat视窗。 解决方法:选择菜单栏...
案例代码: activity_main.xml<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/relativeLayout"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/bg"tools:context=".MainActivity"></RelativeLayout> AndroidView.javapackage com.ex...
要使用一个ContentProvider,必须要知道的是它所能匹配的Uri及其数据存储的表的结构。首先想办法找到访问短信及联系人数据的ContentProvider能接受的Uri:到github上找对应ContentProvider的源码:https://github.com/android 有好多个,哪一个才是短信数据的ContentProvider呢?在filters输入框:输入telephony。 现在只有一个了,打开: 装有git的话,可以选择clone到本地,没有的话,就选择下载zip包就行了。 进入src目录中,Sm...
GridView显示不完整的原因是因为,他的外层也套用了一个滑动的控件,这个解决办法是:重写GridView,是控制GridView不能滚动,就是写一个类继承GridView 代码如下:publicclassMyGridViewextends GridView { public MyGridView(Context context) {super(context); }//设置不滚动 @Overrideprotectedvoid onMeasure(int widthMeasureSpec, int heightMeasureSpec) {int expandSpec=MeasureSpec.makeMeasureSpec(In...
Android:日常学习笔记(9)———探究广播机制引入广播机制Andorid广播机制 广播是任何应用均可接收的消息。系统将针对系统事件(例如:系统启动或设备开始充电时)传递各种广播。通过将 Intent 传递给 sendBroadcast()、sendOrderedBroadcast() 或 sendStickyBroadcast(),您可以将广播传递给其他应用。 Android提供了一套完整的API,允许应用程序自由地发送和接受广播。发送广播使用Intent,接受广播使用 广播接收器(Boradca...
android 端可以通过两种方式去Debug: 一、在手机的设置功能里,开发者模式 Enable,如下图: http://blog.bluetooth.com/debugging-bluetooth-with-an-android-app然后在手机的根目录下有一个名类似叫:btsnoop_hci.log 的日志.通过工具 Wireshark 查看日志:host对应的是主机, controller对应的是控制器。 Android端查看蓝牙日志:http://www.fte.com/webhelp/sodera/Content/Documentation/WhitePapers/BPA600/Encryption/Getti...