Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Write any one line of below code</p> <p>MultipleButton.java</p> <pre><code>public class MultipleButton extends Activity { String night; Button mBtn1, mBtn2, mBtn3, mBtn4, mBtn5; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mBtn1=(Button)findViewById(R.id.button1); mBtn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub night="button1"; Intent intent = new Intent(); intent.setClass(MultipleButton.this, My_videos.class); intent.putExtra("video", night); startActivity(intent); } }); mBtn2=(Button)findViewById(R.id.button2); mBtn2.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub night="button2"; Intent intent = new Intent(); intent.setClass(MultipleButton.this, My_videos.class); intent.putExtra("video", night); startActivity(intent); } }); mBtn3=(Button)findViewById(R.id.button3); mBtn3.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub night="button3"; Intent intent = new Intent(); intent.setClass(MultipleButton.this, My_videos.class); intent.putExtra("video", night); startActivity(intent); } }); mBtn4=(Button)findViewById(R.id.button4); mBtn4.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub night="button4"; Intent intent = new Intent(); intent.setClass(MultipleButton.this, My_videos.class); intent.putExtra("video", night); startActivity(intent); } }); mBtn5=(Button)findViewById(R.id.button5); mBtn5.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub night="button5"; Intent intent = new Intent(); intent.setClass(MultipleButton.this, My_videos.class); intent.putExtra("video", night); startActivity(intent); } }); } } </code></pre> <p>My_videos.java</p> <pre><code>public class My_videos extends Activity { private VideoView vid; String night; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.video); Bundle bdl = getIntent().getExtras(); night = bdl.getString("video"); vid = (VideoView) findViewById(R.id.videoView1); if (night.equalsIgnoreCase("button1")) { vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.a)); vid.setMediaController(new MediaController(My_videos.this)); vid.requestFocus(); vid.start(); } else if (night.equalsIgnoreCase("button2")) { vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.b)); vid.setMediaController(new MediaController(My_videos.this)); vid.requestFocus(); vid.start(); } else if (night.equalsIgnoreCase("button3")) { vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.c)); vid.setMediaController(new MediaController(My_videos.this)); vid.requestFocus(); vid.start(); } else if (night.equalsIgnoreCase("button4")) { vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.d)); vid.setMediaController(new MediaController(My_videos.this)); vid.requestFocus(); vid.start(); } else if (night.equalsIgnoreCase("button5")) { vid.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.e)); vid.setMediaController(new MediaController(My_videos.this)); vid.requestFocus(); vid.start(); } } } </code></pre> <p>main.xml:-</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button" /&gt; &lt;Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button" /&gt; &lt;Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button" /&gt; &lt;Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button" /&gt; &lt;Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Button" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>instead of your My_videos.java class</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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