Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying the result in another activity
    primarykey
    data
    text
    <p>Asked this question before but didn't get it properly.Iam a beginner.So it's difficult to cope initially.The output to the program is displayed in the same activity.I just want to see the result displayed in the another activity. Below is the mainActivity.java</p> <pre><code>package com.example.knowyourself; import android.os.Bundle; public class MainActivity extends Activity { Button submit; String temp,out; DatePicker dt; int day, month, year, choice; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); addListenerOnButton(); } public void addListenerOnButton() { submit = (Button) findViewById(R.id.button1); dt = (DatePicker) findViewById(R.id.datePicker1); submit.setOnClickListener(new OnClickListener() { public void onClick(View v) { day = dt.getDayOfMonth(); month = dt.getMonth(); year = dt.getYear(); choice = (day + month + year) % 5; switch (choice) { ........... ........... out="You are"+temp; Toast t = Toast.makeText(MainActivity.this,out, Toast.LENGTH_SHORT); t.show(); } }); } } </code></pre> <p>activity_main.xml</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/green" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="76dp" android:text="@string/Date" android:textAppearance="?android:attr/textAppearanceLarge" tools:ignore="HardcodedText" android:textColor="@color/blue" android:textScaleX="0.9" /&gt; &lt;DatePicker android:id="@+id/datePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginTop="61dp" android:background="@color/lightblue" /&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/datePicker1" android:layout_centerHorizontal="true" android:layout_marginTop="54dp" android:text="" tools:ignore="HardcodedText" android:background="@drawable/one" /&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload