Android处理UI控件事件
来源:互联网 发布:淘宝商品标题权重 编辑:程序博客网 时间:2024/06/05 08:45
布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/screen"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"><TextView android:id="@+id/text1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:textSize="24sp"android:text="@string/text1" /><Button android:id="@+id/button1"android:layout_width="80sp"android:layout_height="wrap_content"android:layout_gravity="center"android:text="@string/red"/><Button android:id="@+id/button2"android:layout_width="80sp"android:layout_height="wrap_content"android:layout_gravity="center"android:text="@string/green"/></LinearLayout>MainActivity.java
package com.android.basicapp;import android.app.Activity;import android.os.Bundle;import android.graphics.Color;import android.widget.Button;import android.widget.TextView;import android.view.View;import android.view.View.OnClickListener;import android.util.Log;public class TestEvent1 extends Activity {private static final String TAG = "TestEvent1";public TestEvent1() {}@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.testevent);final TextView Text = (TextView) findViewById(R.id.text1); // 获得句柄final Button Button1 = (Button) findViewById(R.id.button1);final Button Button2 = (Button) findViewById(R.id.button2);Button1.setOnClickListener(new OnClickListener() { // 实现行为功能public void onClick(View v) {Text.setBackgroundColor(Color.RED);}});Button2.setOnClickListener(new OnClickListener() {public void onClick(View v) {Text.setBackgroundColor(Color.GREEN);}});}}
0 0
- Android处理UI控件事件
- UI控件 - 事件处理
- Android UI事件处理
- Android UI事件处理
- Android UI事件处理
- Android UI事件处理
- Android UI事件处理
- Android UI事件处理
- android ui事件处理分析
- Android UI事件处理[isInTouchMode()]
- android的UI事件处理
- Android基础————UI控件以及控件事件处理详解
- Android UI事件处理、focus处理
- Android UI事件处理、focus处理
- Android UI事件处理、focus处理
- Android--UI事件监听器及其处理程序
- android--UI组件的事件处理--01
- Android UI布局和事件处理小结
- dcm文件转jpg或者bmp
- java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener问题解决
- 整理了一下机架、机槽、机盘的东西
- layer-list的基本使用介绍
- -bash: make: command not found的解决办法
- Android处理UI控件事件
- 程序猿学习笔记(二)
- Could not load file or assembly 'vjscor, Version=2.0.0.0, Culture=neutral, 问题解决方法
- 【Android】Rxjava操作符系列(二)
- java,SimpleDateFormat的format()方法
- 使用qemu运行指定内核
- C/C++函数参数读取顺序
- VS2013知识点总结
- 在opencv3中利用SVM进行图像目标检测和分类