• 第二章课后练习 Q1


     1 <LinearLayout android:layout_width="fill_parent"
     2     android:layout_height="fill_parent"
     3     android:orientation="vertical"
     4     xmlns:android="http://schemas.android.com/apk/res/android" >
     5     <LinearLayout
     6         android:layout_width="wrap_content"
     7         android:layout_height="wrap_content"
     8         android:layout_gravity="center">
     9         <EditText
    10             android:id="@+id/edit"
    11             android:layout_width="wrap_content"
    12             android:layout_height="wrap_content"
    13             android:hint="文本输入框"
    14             />
    15     </LinearLayout>
    16     <LinearLayout
    17         android:layout_width="wrap_content"
    18         android:layout_height="wrap_content"
    19         android:layout_gravity="center">
    20         <Button
    21             android:id="@+id/bt"
    22             android:layout_width="wrap_content"
    23             android:layout_height="wrap_content"
    24             android:text="按钮"
    25             />
    26     </LinearLayout>
    27     <LinearLayout
    28         android:layout_width="wrap_content"
    29         android:layout_height="wrap_content"
    30         android:layout_gravity="center">
    31         <TextView
    32             android:id="@+id/txt"
    33             android:layout_width="wrap_content"
    34             android:layout_height="wrap_content"
    35             android:text="文本标签"
    36             />
    37     </LinearLayout>
    38 </LinearLayout>
     1 package com.android.myapplication;
     2 
     3 import androidx.appcompat.app.AppCompatActivity;
     4 
     5 import android.annotation.SuppressLint;
     6 import android.os.Bundle;
     7 import android.view.View;
     8 import android.widget.Button;
     9 import android.widget.EditText;
    10 import android.widget.TextView;
    11 
    12 public class MainActivity extends AppCompatActivity {
    13 
    14     public String txt;
    15 
    16     @Override
    17     protected void onCreate(Bundle savedInstanceState) {
    18         super.onCreate(savedInstanceState);
    19         setContentView(R.layout.activity_main);
    20         final EditText editText=findViewById(R.id.edit);
    21         Button button=findViewById(R.id.bt);
    22         final TextView textView=findViewById(R.id.txt);
    23         button.setOnClickListener(new View.OnClickListener() {
    24             @Override
    25             public void onClick(View v) {
    26                 textView.setText(editText.getText().toString());
    27             }
    28         });
    29     }
    30 }
  • 相关阅读:
    Centos-获取远程主机对应端口信息-telnet
    Centos-跟踪数据传输路由状态-traceroute
    Centos-本机网络连接、运行端口和路由表等信息-netstat
    Centos-远程拷贝-scp
    Centos-配置网络或显示当前网络接口状态-ifconfig
    Centos-挂载和卸载分区-mount
    Centos-退出抽取设备-eject
    Centos-强制将内存中数据写入磁盘-sync
    Centos-检查文件系统并尝试修复-fsck
    数据结构-静态查找表
  • 原文地址:https://www.cnblogs.com/xiaowangdatie/p/13994604.html
Copyright © 2020-2023  润新知