Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout android:layout_height="match_parent"
- android:layout_width="match_parent"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <EditText
- android:id="@+id/editText"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_above="@+id/hoten"
- android:layout_marginBottom="174dp"
- android:drawableLeft="@drawable/icons"
- android:ems="10"
- android:hint="Tài Khoản"
- android:inputType="textPersonName"
- android:textColor="#ff00"
- android:textColorHint="#ff0"
- android:textSize="26sp" />
- <Button
- android:id="@+id/hoten"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:layout_alignParentRight="true"
- android:layout_alignParentBottom="true"
- android:layout_marginEnd="0dp"
- android:layout_marginRight="0dp"
- android:layout_marginBottom="424dp"
- android:text="Lấy nội dung" />
- </RelativeLayout>
- package com.example.edittext;
- import androidx.appcompat.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.Toast;
- public class MainActivity extends AppCompatActivity {
- EditText edtNoiDung;
- Button btnClick;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- edtNoiDung=(EditText) findViewById(R.id.editText);
- btnClick=(Button) findViewById(R.id.hoten);
- btnClick.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String noiDung=edtNoiDung.getText().toString();
- Toast.makeText(MainActivity.this, noiDung, Toast.LENGTH_SHORT).show();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement