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

  • 相关阅读:
    CCF NOI1062 计算曼哈顿距离
    CCF NOI1061 Wifi密码
    CCF NOI1073 放苹果
    CCF NOI1072 爬楼梯
    CCF NOI1071 Pell数列
    CCF NOI1064 计算斐波那契第n项
    NOI训练行动路线图
    CCF NOI1060 雷同检测
    CCF NOI1059 表达式求值
    CCF NOI1057 石头剪刀布
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679798.html
Copyright © 2011-2022 走看看