fill_parent 填充父窗体
wrap_content 包裹内容
android:orientation="horizontal" 指定朝向
horizontal 横向排列
vertical 纵向排列
打电话:
布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number" />
<EditText
android:id="@+id/et_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入电话号码" />
<Button
android:id="@+id/bt_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="拨打" />
</LinearLayout>
发短信:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:padding="10dp"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入电话号码:" />
<EditText
android:id="@+id/et_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="请输入电话号码" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入短信内容:" />
<EditText
android:id="@+id/et_sms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:lines="8" />
<Button
android:onClick="send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="发送" />
</LinearLayout>
监听:
①、自定义一个类 实现view的一个点击监听;
②、在布局文件中写一个属性android:onClick="",写入的这个属性在对应的.Java文件中一定要有一个一样的方法,而且一定是公开的,必须带有形参。