Android开发入门(二)
来源:互联网 发布:买家如何注册淘宝客 编辑:程序博客网 时间:2024/06/05 04:50
3 Android的生命周期
4. 一个简单的android应用程序,输入一个手机号码,然后显示输入的号码
界面布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="请输入手机号"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<EditText
android:text=""
android:id="@+id/EditText01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></EditText>
<Button
android:text="输入"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></Button>
</LinearLayout>
代码:
public class ApiDemos extends Activity {
/** Called when the activity is first created. */
private EditText mEdit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); //设置显示的内容
Button mButton;
mButton = (Button)findViewById(R.id.Button01); //初始化
mEdit = (EditText)findViewById(R.id.EditText01); //初始化
//按钮单击事件
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast toast = Toast.makeText(ApiDemos.this,mEdit.getText().toString(), Toast.LENGTH_LONG);
toast.show();
}
});
}
}
- Android开发入门(二)
- Android开发入门(二)之HellWord
- Android 自定义控件开发入门(二)
- Android 自定义控件开发入门(二)
- Android开发之BUG专讲:入门篇(二)
- 【入门篇(二)】ANDROID开发之BUG专讲
- intellij idea开发android从入门到精通(二)
- Android开发入门(二)——基本语法2
- Android开发入门学习笔记之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Android JNI开发入门之二
- Servlet开发入门(二)
- 八款JS框架介绍及比较
- android loginDemo +WebService用户登录验证
- 【QTP】无意中发现了QTP11.5(UFT)的一个新功能。
- 纯图片高度自适应圆角框的制作
- SQL批量删除数据表中指定字段对应的所有约束
- Android开发入门(二)
- 基础加强_JavaBean,反射和内省,BeanUtils工具
- 拉格朗日 SVM KKT
- Perl 中的线程(2)
- 1175 连连看
- Python 中 字符串与字典间转换
- AE创建拓扑
- 关于Tomcat
- 冯大辉:十年莽撞 IT 路