It may seem simple, but I can't get it to work. I have two activities. The first one is the form, and the second shows the data from the JSON file based on the values ββentered in the first step.
Therefore, I am trying to make a simple version. I have an EditText and a button, so when they click the button, everything that was in the EditText will be in the TextView of the next action.
Here is my code: Main activity
static TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView) findViewById(R.id.editText1); } @Override public boolean onCreateOptionsMenu(Menu menu) {
Core XML
<EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/textView1" android:layout_centerHorizontal="true" android:ems="10" android:hint="Enter Text to transfer" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Transfer it" android:onClick="transferIT" />
Second activity
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_page);
Second xml
<TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="58dp" />
So I created a method for the EditText data, and in another operation, I call it to access it. Currently, when I click the button, it stops working. So what is your decision about the availability of form data in another activity?
java android
user3026034
source share