Android复习之按钮button
来源:互联网 发布:用手机发布淘宝宝贝 编辑:程序博客网 时间:2024/04/30 15:07
Android复习之按钮button
activity_main.xml代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is a button"/>
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is a button"/>
</RelativeLayout>
java代码如下:
package com.example.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setTitle("click button");
}
});
}
}
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button) findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setTitle("click button");
}
});
}
}
显示结果如下:
0 0
- Android复习之按钮button
- Android控件复习:按钮(Button)
- Android简单复习之按钮
- Android开发 之 基本按钮Button
- Android学习路之Button(按钮)与ImageButton(图像按钮)
- Android自定义Button按钮
- android 控件 按钮(Button)
- 【Android】05、Button按钮
- Android中的Button按钮
- android用户界面之按钮(Button)教程实例汇
- android用户界面之按钮(Button)教程实例汇
- android用户界面之按钮(Button)教程实例汇
- android用户界面之按钮(Button)教程实例汇
- Android UI之三个Button按钮仿Iphone效果
- Android学习2控件之Button按钮组件
- Android之Button按钮点击事件的三种方式
- Android之Button按钮点击事件的三种方法
- Android开发基础之Button按钮的简单用法
- webkit滚动条浅析
- ActionScript拖动元件
- 梦中的婚礼 c++--beep()
- POJ 2653 Pick-up sticks(计算几何 求线段交点)
- VC++/MFC中调用CHM帮助文档的方法
- Android复习之按钮button
- Android Permission Denied
- 丢失了文件localhost.localdomain.pid和mysql.sock,怎么办?
- Objective-C:属性
- Vim简明教程【CoolShell】
- cocos2d学习之路四(添加遥控杆)
- 如何“排外”处理多点触摸事件
- Analyzing PDF Malware - Part 3A
- wifi 流程