Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:gravity="center"
- tools:context=".MainActivity">
- <EditText
- android:layout_width="310dp"
- android:layout_height="70dp"
- android:hint="Enter Your Name"
- android:textColorHint="@color/colorPrimaryDark"
- android:id="@+id/name"
- android:textColor="@color/colorPrimaryDark"
- android:textSize="30dp"/>
- <Button
- android:id="@+id/btn"
- android:layout_marginTop="20dp"
- android:textColor="#fff"
- android:textSize="30dp"
- android:background="@color/colorPrimaryDark"
- android:text=" Click Here "
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- <TextView
- android:id="@+id/result"
- android:text="Your name is ?"
- android:layout_marginTop="30dp"
- android:textColor="@color/colorAccent"
- android:textSize="30dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </LinearLayout>
- package com.example.administrator.class2;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- EditText name;
- Button btn;
- TextView result;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- name = (EditText) findViewById(R.id.name);
- btn = (Button) findViewById(R.id.btn);
- result = (TextView) findViewById(R.id.result);
- btn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- result.setText("Your name is " + name.getText().toString());
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement