2.0 Intent Main

Download as pdf
Download as pdf
You are on page 1of 2
File - :\Userslaiun\Desktop\BMS\2ND SEMIMAD\AndroidStudioProjacslintentiapp\sreimain\javalcomexampleintentIMainAc 1 package com.example. intent; 2 // 5 // 6 // 7// 8 // 9 // 10 // a // 12 import 13 androidx.appcompat. app. AppCompatActivity; 14 15 import android.content. Intent; 16 import android.os.Bundle; 17 import android.widget.EditText; 18 import android.widget.TextView; 19 import android.widget.Button; 20 import android.view. View; 2a 22 public class MainActivity extends AppCompatActivity { 23 public static final String Efn = "com.example.MyIndent. Efn"; 24 public static final String Eus = "com.example.MyIndent. Eus"; 25 public static final String Ed = "com.example.MyIndent. Ed"; 26 @Override 27 protected void onCreate(Bundle savedInstanceState) { 28 super. onCreate(savedInstanceState) ; 29 setContentView(R. Layout.activity_main) ; 30 Button button = (Button) findViewById(R.id.Btn); 3a button. setOnClickListener(new View. OnClickListener of 32 33 public void onClick(View view) 34 { 35 DisActivity(); 36 37 + 38 ni 39 + 49 public void DisActivity() { 41 EditText et1 = (EditText) findViewById(R.id.Name); 42 EditText et2 = (EditText) findViewById(R.id.Usn) ; 43 EditText et3 = (EditText) findViewByld(R.id.Dep) ; Page 1 of2 File - :\Userslaiun\Desktop\BMS\2ND SEMIMAD\AndroidStudioProjacslintentiappisreimain\javalcomexampleintentIMainAc a4 45 String fn = et1.getText().toString(); 46 String usn = et2.getText().toString(); 47 String dept = et3.getText().toString(); 48 49 Intent intent = new Intent(this,DisplayActivity.class) ; 50 intent. putExtra(Efn, fn); 51 intent .putExtra(Eus, usn); 52 intent .put€xtra(Ed, dept); 53 startActivity (intent); 54 55 56 ¥ 57} Page 2 of2

You might also like