Wednesday, 28 February 2018

submit a sign up button alldata pass to next text view activity

submit a sign up button
all typed data pass to next 
text view activity ,
data pass through last activity   


sign_up  activity preview :-




make new activity pass following step -  

right clik on app bar in project structure .> new>activity>empty activity> name file text_view  



now we have

1) activity_sign_up.xml
2)sign_up.java
3)activity_text_view.xml
4)text_view.java




code :-

1) activity_sign_up.xml
 
     in that activity we are use  
   </LinearLayout>
    </ScrollView>
as shown preview on top


activity_sign_up.xml

<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout 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"
    tools:context="com.example.store.n01.Sign_up">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


            <EditText
                android:id="@+id/edit_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:ems="10"
                android:inputType="textPersonName"
                android:hint="Name" />

            <EditText
                android:id="@+id/edt_mobileno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/edit_name"
                android:layout_alignRight="@+id/edit_name"
                android:layout_below="@+id/editText4"
                android:ems="10"
                android:inputType="textPersonName"
                android:hint="@string/mobile_no" />

            <EditText
                android:id="@+id/edt_passwardsu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/editText5"
                android:layout_alignRight="@+id/editText5"
                android:layout_below="@+id/editText5"
                android:ems="10"
                android:hint="@string/passward"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/edt_mothername"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/editText7"
                android:layout_alignRight="@+id/editText7"
                android:layout_below="@+id/editText7"
                android:ems="10"
                android:hint="@string/mother_name"
                android:inputType="textPersonName" />

            <CheckBox
                android:id="@+id/checkBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/term_and_condition" />

            <Button
                android:id="@+id/btn_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:background="@drawable/btn_all"
                android:text="@string/sign_up"
                android:textAlignment="center"
                android:textSize="19sp"
                android:padding="10dp"
                android:gravity="center"/>


        </LinearLayout>
    </ScrollView>
</android.widget.RelativeLayout>


2)sign_up.java


package com.example.store.n01;

import android.content.Intent;
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.Toast;

public class Sign_up extends AppCompatActivity {
    EditText edit_name ,edt_mobileno ,edt_passwardsu ,edt_mothername;
    Button btn_signup ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_up);
        edit_name = (EditText)findViewById(R.id.edit_name);
        edt_mobileno = (EditText)findViewById(R.id.edt_mobileno);
        edt_passwardsu=(EditText)findViewById(R.id.edt_passwardsu);
        edt_mothername= (EditText)findViewById(R.id.edt_mothername);

        btn_signup =(Button)findViewById(R.id.btn_signup);

        btn_signup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String s1 = edit_name.getText().toString();
                String s2 =edt_mobileno.getText().toString();
                String s3 =edt_passwardsu.getText().toString();
                String s4 =edt_mothername.getText().toString();

                Intent i = new Intent(getApplicationContext(),text_view.class);
                i.putExtra("name",edit_name.getText().toString());
                i.putExtra("mobileno",edt_mobileno.getText().toString());
                i.putExtra("mothername",edt_mothername.getText().toString());
                i.putExtra("passwardsu",edt_passwardsu.getText().toString());

                startActivity(i);

               // Toast.makeText(Sign_up.this, s1 +"\n"+"\n"+s2 +"\n"+ s3+"\n"+s4, Toast.LENGTH_SHORT).show();

            }
        });

    }

}




3)activity_text_view.xml

activity preview :-

activity_text_view.xml

<?xml version="1.0" encoding="utf-8"?>
<android.widget.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"
     >


    <TextView
        android:id="@+id/name_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />

    <TextView
        android:id="@+id/mobileno_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />

    <TextView
        android:id="@+id/passward_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />

    <TextView
        android:id="@+id/mothername_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />
</android.widget.LinearLayout>


4)text_view.java

package com.example.store.n01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class text_view extends AppCompatActivity {

    TextView name_tv,mobileno_tv,passward_tv,mothername_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text_view);

        name_tv = (TextView)findViewById(R.id.name_tv);
        mobileno_tv = (TextView)findViewById(R.id.mobileno_tv);
        passward_tv= (TextView)findViewById(R.id.passward_tv);
        mothername_tv= (TextView)findViewById(R.id.mothername_tv);

        name_tv.setText(getIntent().getStringExtra("name"));
        mobileno_tv.setText(getIntent().getStringExtra("mobileno"));
        passward_tv.setText(getIntent().getStringExtra("mothername"));
        mothername_tv.setText(getIntent().getStringExtra("passwardsu"));

    }
}


it was pass a data 1st activity to other activity run


No comments:

Post a Comment

B Remi Calculator

Loan Calculator Loan Calculator Loan Amount PF Cross Sell (LI % GI) No Yes EMI CARD No Ye...