按键事件主要在EdTex中使用,用王监听输入的内容。在布局文件中加入一个 EditText。
MainActivity对应的布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/liner_click"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/button_click"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我是button按钮"/>
<TextView
android:id="@+id/text_click"
android:layout_width="match_parent"
android:layout_height="wrap