第一次接触android开发,之前也没有java基础,废了很多周折。
做一点简单的记录,以便日后复习
创建完一个android项目后会自动生成src、gen、res目录
src目录用于存放java代码,gen目录一般由系统自动生成,不需要去改动他
res目录存放app中的资源,如语言包,图片,以及界面的布局文件,除了图片等资源配置文件一般都是xml文件
res目录文件夹列表
drawable内默认放置了程序的图标文件,按照后缀猜测为hdpi内放置的是高分辨率的icon,l和m分别为low和middle的缩写(个人猜测,尚未证实)
layout内放置了程序的布局配置,其写法类似flex的mxml文件,可以用sdk内置的tag,应该也可以自己定制
View Code
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_height="22dip" android:id="@+id/textView1" android:layout_x="10dip" android:text="自己的号码" android:layout_width="80dip" android:layout_y="25dip" android:textColor="#ffffff"></TextView>
<EditText android:layout_height="22dip" android:text="" android:numeric="integer" android:layout_width="150dip" android:id="@+id/myPhoneNo" android:layout_x="100dip" android:layout_y="25dip" android:textColor="#000000" android:background="#ffffff"></EditText>
<TextView android:layout_height="22dip" android:id="@+id/textView2" android:layout_x="10dip" android:text="拨打的号码" android:layout_width="80dip" android:layout_y="80dip" android:textColor="#ffffff"></TextView>
<EditText android:layout_height="22dip" android:text="" android:numeric="integer" android:layout_x="100dip" android:layout_width="150dip" android:id="@+id/callPhoneNo" android:layout_y="80dip" android:textColor="#000000" android:background="#ffffff"></EditText>
<Button android:layout_height="50dip" android:id="@+id/callBTN" android:text="呼叫" android:layout_x="105dip" android:layout_width="50dip" android:layout_y="132dip" ></Button>
<TextView android:layout_height="wrap_content" android:id="@+id/resultText" android:text="" android:textColor="#ffffff" android:layout_width="wrap_content" android:layout_x="40dip" android:layout_y="240dip"></TextView>
</AbsoluteLayout>
values文件夹内放置了一些开发者定义的语言包,以及配置文件
res目录中的信息修改后,android sdk会自动刷新gen目录下的文件,将res中定义组件以及布局记录下来
View Code
这样在src中就可以同过R
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package nncall.call;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int callBTN=0x7f050004;
public static final int callPhoneNo=0x7f050003;
public static final int myPhoneNo=0x7f050001;
public static final int resultText=0x7f050005;
public static final int textView1=0x7f050000;
public static final int textView2=0x7f050002;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
来调用对应的组件,layout,配置信息等