Android开发之发送短信程序


一、创建 Android工程

Project name: Message

BuildTarget:Android2.2

Application name:sendMessage

Package name:com.dxw.activity

Create Activity: SendMessageActivity

Min SDK Version:8

二、编辑工程 

1.编辑strings.xml文件内容为:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <string name="phone">请输入手机号:</string>  
  4.     <string name="app_name">短信的发送</string>  
  5.     <string name="massage">请输入信息内容:</string>  
  6.     <string name="content">这里输入信息内容</string>  
  7.     <string name="send">发送</string>  
  8. </resources>  

2.编辑main.xml文件内容为:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.         <!-- 请输入手机号码标签 -->  
  8.     <TextView    
  9.         android:layout_width="fill_parent"   
  10.         android:layout_height="wrap_content"   
  11.         android:text="@string/phone"  
  12.     />  
  13.         <!-- 手机号码编辑框 -->  
  14.     <EditText   
  15.         android:id="@+id/number"  
  16.         android:layout_width="wrap_content"  
  17.         android:layout_height="wrap_content"  
  18.         android:hint="这里输入手机号码"  
  19.     />  
  20.         <!-- 请输入手机内容标签 -->  
  21.     <TextView    
  22.         android:layout_width="fill_parent"   
  23.         android:layout_height="wrap_content"   
  24.         android:text="@string/massage"  
  25.     />  
  26.     <!-- 信息内容输入框 -->  
  27.     <EditText   
  28.         android:id="@+id/content"  
  29.         android:layout_width="fill_parent"  
  30.         android:layout_height="45sp"  
  31.         android:minLines="3"  
  32.         android:hint="@string/content"  
  33.     />  
  34.     <!-- 发送按纽 -->  
  35.     <Button   
  36.         android:id="@+id/send"  
  37.         android:layout_width="wrap_content"  
  38.         android:layout_height="wrap_content"  
  39.         android:text="send"  
  40.     />  
  41. </LinearLayout>  

注意,我们在电话号码输入框和拨打电话按钮中添加了android:id属性。如电话号码输入框的android:id=”@+id/mobile”,@代码R.java,+id代码添加id静态内部类,mobile代表向id类中添加一个常量成员。ADT将自动为我们生成常量值。

android:minLines设置信息内容编辑框的最小行数

  • 1
  • 2
  • 下一页

相关内容