-3

I am building an android app in which, on the MainActivity the user enters his/her details like name, phone number, etc., in several EditText fields. I should get all those data, pass them to the SecondActivity and display them on textViews. The transition from MainActivity to second activity is done via an onclick event.

Edit text xml

<EditText
     android:hint="@string/teacher_name_hint"
     android:layout_width="match_parent"
     android:layout_height="0dp"
     android:layout_weight="10"
     android:id="@+id/teacher_name"
     android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,., "
     android:inputType="textPersonName"
     android:maxLength="42"
     android:maxLines="2"
     android:minLines="1"
     android:textColorHint="@color/abc_secondary_text_material_light" />

Onclick Event

public void roll_sheet_Activity(View v)
{
    Intent i = new Intent(MainActivity.this,Roll_sheet.class);
    startActivity(i);
}
vss
  • 1,093
  • 1
  • 20
  • 33
Ved Sarkar
  • 347
  • 2
  • 8
  • 18
  • pass data one activity to other activity@Ved Sarkar – Anand Diamond Aug 18 '17 at 07:18
  • pass your data from one activity to another activity https://stackoverflow.com/questions/18146614/how-to-send-string-from-one-activity-to-another?answertab=votes#tab-top – Vinayak B Aug 18 '17 at 07:20
  • using bundle you can send data from one activity to another activity – skyshine Aug 18 '17 at 07:20
  • Please try searching for these things first: https://stackoverflow.com/questions/18481516/passing-string-from-edit-text-to-another-activity https://stackoverflow.com/questions/15052019/how-to-send-text-from-one-activity-to-another-activity https://stackoverflow.com/questions/36172176/how-to-send-multiple-edittexts-in-to-another-activity-as-a-textviews-like-login https://stackoverflow.com/questions/6182906/how-to-pass-edit-text-data-in-form-of-string-to-next-activity https://stackoverflow.com/questions/36172176/how-to-send-multiple-edittexts-in-to-another-activity-as-a-textviews-like-login – Mike M. Aug 18 '17 at 07:24

1 Answers1

0

Pass data using intent

public void roll_sheet_Activity(View v)
{
Intent intent = new Intent(getBaseContext(), NextActivity.class);
intent.putExtra("stringName", stringName);
startActivity(intent);
}

on the next activity:

String s = getIntent().getStringExtra("stringName");
kiLLua
  • 443
  • 1
  • 6
  • 17