Step 1:
Create one new Android Application Project named as MyTest
Step 2:
Take elements 1)Textview 2)EditText 3)Button As below Picture
Step 3:
now open MainActivity.java file
(Location in folder src>com.example.MyTest>MainActivity.java)
code as below
package com.example.mytest;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView lbl=(TextView) findViewById(R.id.textView1);
final EditText edtxt=(EditText) findViewById(R.id.editText1);
Button btn=(Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String str=edtxt.getText().toString();
lbl.setText(str);
}
});
}
}
Step 4:
Now run your Application in Emulater
Create one new Android Application Project named as MyTest
Step 2:
Take elements 1)Textview 2)EditText 3)Button As below Picture
Step 3:
now open MainActivity.java file
(Location in folder src>com.example.MyTest>MainActivity.java)
code as below
package com.example.mytest;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView lbl=(TextView) findViewById(R.id.textView1);
final EditText edtxt=(EditText) findViewById(R.id.editText1);
Button btn=(Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
String str=edtxt.getText().toString();
lbl.setText(str);
}
});
}
}
Step 4:
Now run your Application in Emulater