Thursday, 4 January 2018

Send Activity

Hi All,

See the code to send activity.

Do these steps beforehand
1. Create a new class by right clicking the package in src folder
2. Copy paste the code of first activity and change class name.
3. Create a new xml file by right clicking the layout folder under res folder
4. In the First activity add a function HUP() by adding onclick handler in the corresponding layout file

public void HUP(View v)
    {
        EditText msg=(EditText)findViewById(R.id.txtName);
        String txt=msg.getText().toString();
        Intent in=new Intent(MainActivity.this,Activity2.class);
        in.putExtra("msg", txt);
        startActivity(in);
    
    }

No comments:

Post a Comment