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();
    }
    });
    }
    }

  • 相关阅读:
    JS条件判断小技巧
    简单实现节流函数和防抖函数(转载)
    一篇常做错的经典JS闭包面试题
    前端冷知识集结
    闭包
    仔细认识setInterval
    仔细认识setTimeout
    单方向指定时间内的匀速运动
    图片延迟加载
    优化网页上的gif
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679798.html
Copyright © 2011-2022 走看看