SHARE
TWEET

Untitled

a guest Sep 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout android:layout_height="match_parent"
  3.     android:layout_width="match_parent"
  4.     xmlns:android="http://schemas.android.com/apk/res/android">
  5.  
  6.     <EditText
  7.         android:id="@+id/editText"
  8.         android:layout_width="match_parent"
  9.         android:layout_height="wrap_content"
  10.         android:layout_above="@+id/hoten"
  11.         android:layout_marginBottom="174dp"
  12.         android:drawableLeft="@drawable/icons"
  13.         android:ems="10"
  14.         android:hint="Tài Khoản"
  15.         android:inputType="textPersonName"
  16.         android:textColor="#ff00"
  17.         android:textColorHint="#ff0"
  18.         android:textSize="26sp" />
  19.  
  20.     <Button
  21.         android:id="@+id/hoten"
  22.         android:layout_width="match_parent"
  23.         android:layout_height="wrap_content"
  24.         android:layout_alignParentEnd="true"
  25.         android:layout_alignParentRight="true"
  26.         android:layout_alignParentBottom="true"
  27.         android:layout_marginEnd="0dp"
  28.         android:layout_marginRight="0dp"
  29.         android:layout_marginBottom="424dp"
  30.         android:text="Lấy nội dung" />
  31. </RelativeLayout>
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. package com.example.edittext;
  39.  
  40. import androidx.appcompat.app.AppCompatActivity;
  41.  
  42. import android.os.Bundle;
  43. import android.view.View;
  44. import android.widget.Button;
  45. import android.widget.EditText;
  46. import android.widget.Toast;
  47.  
  48. public class MainActivity extends AppCompatActivity {
  49.  
  50.     EditText edtNoiDung;
  51.     Button btnClick;
  52.     @Override
  53.     protected void onCreate(Bundle savedInstanceState) {
  54.         super.onCreate(savedInstanceState);
  55.         setContentView(R.layout.activity_main);
  56.         edtNoiDung=(EditText) findViewById(R.id.editText);
  57.         btnClick=(Button) findViewById(R.id.hoten);
  58.         btnClick.setOnClickListener(new View.OnClickListener() {
  59.             @Override
  60.             public void onClick(View view) {
  61.                 String noiDung=edtNoiDung.getText().toString();
  62.                 Toast.makeText(MainActivity.this, noiDung, Toast.LENGTH_SHORT).show();
  63.  
  64.             }
  65.         });
  66.     }
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top