zoukankan      html  css  js  c++  java
  • android为按钮事件进行监听过程

    activity_main:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
    android:id="@+id/tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/app_name"
    android:textSize="30dp"
    android:layout_gravity="center"
    android:layout_marginTop="20dp"/>

    <Button
    android:id="@+id/btnStart"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:text="@string/hello_world"
    />
    </LinearLayout>

    import android.widget.Toast;

    /**
    * Created by DELL on 2016/7/13.
    */
    public class HelloAndroid extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.activity_main);

    findViewById(R.id.btnStart).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    System.out.println("别点我了,好吗!");
    Toast.makeText(getApplicationContext(), "别点我了,好吗!", Toast.LENGTH_SHORT).show();
    }
    });
    }
    }

  • 相关阅读:
    mysql用户
    mysql字符集
    tidb之一致性算法raft学习
    更新港资股票数据
    php中的时区设置
    PHP 中的注释
    python下如何处理windows的路径名
    安装第三方模块
    偏函数
    装饰器没学明白,记录一下,以后再学
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679798.html
Copyright © 2011-2022 走看看