Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8243049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:22:43+00:00 2026-06-07T21:22:43+00:00

the app that I am creating has two buttons on the main screen, that

  • 0

the app that I am creating has two buttons on the main screen, that then link to another screen. However, when I link to the other screeen, I do get the xml file to show up, but the class associated with that file does not seem to work. Like I have buttons on my other screen that do not do what they are supposed to (I have a back button that does not go back to the main page, and an image button that does not link to the video.xml screen).

Does anyone know the problem?

Main_Activity.java

    import android.app.Activity;
    import android.content.Intent;

    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;

    import android.widget.Button;


    public class MainActivity extends Activity {





    @Override
        public void onCreate(Bundle savedInstanceState) 
    {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);





    final Button videoNext = (Button) findViewById(R.id.videoButton) ; 

    videoNext.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

Intent myIntent = new Intent(MainActivity.this, Screen2.class);
        MainActivity.this.startActivity(myIntent);
        //setContentView(R.layout.screen2xml);
        }
    });

    Button newsNext = (Button) findViewById(R.id.newsButton);
    newsNext.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

         Intent myIntent = new Intent(MainActivity.this, Screen1.class);
        MainActivity.this.startActivity(myIntent);
        //setContentView(R.layout.screen2xml);
        }
    });
    }

    }

Screen 2.java

import android.os.Bundle;

import android.app.Activity;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;


public class Screen2 extends Activity {




  public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen2xml);


    Button back = (Button)this.findViewById(R.id.backButton);
    back.setBackgroundColor(5);
    back.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
        setContentView(R.layout.activity_main);
        //finish();

            //Intent intent = new Intent(SImpleRssReader2Activity.this, rahul.SRR2.SimpleRssReader2.Screen1.class); 
        //startActivity(intent);

        }
    });

    ImageButton vid1 = (ImageButton)this.findViewById(R.id.imageButton1);
    vid1.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
        setContentView(R.layout.video);

        //finish();

            //Intent intent = new Intent(SImpleRssReader2Activity.this, rahul.SRR2.SimpleRssReader2.Screen1.class); 
        //startActivity(intent);

        }
    });



    }
}

screen2xml.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:paddingBottom="2dp"
    android:paddingLeft="2dp"
    android:paddingRight="2dp"
    android:paddingTop="2dp" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/backButton" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:ems="10"
        android:inputType="textMultiLine" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="120dp"
        android:ems="10"
        android:inputType="textMultiLine" >

        <requestFocus />
    </EditText>

    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/button1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="23dp"
        android:background="@drawable/ic_button1"
        android:src="@drawable/ic_button1" android:contentDescription="TODO"/>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText1"
        android:layout_below="@+id/imageButton1"
        android:layout_marginTop="81dp"
        android:ems="10"
        android:inputType="textMultiLine"
        android:text="@string/text" />

</RelativeLayout>

Video1.java

import java.io.File;

import android.net.Uri;

import android.os.Bundle;
import android.os.Environment;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;

public class Video1 extends Activity {


    VideoView videoView;
    @Override
public void onCreate(Bundle savedInstanceState) 
    {
    super.onCreate(savedInstanceState);



    videoView = (VideoView) findViewById(R.id.videoView1);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
//Set video link (mp4 format )
    Uri video = Uri.parse("http://vimeo.com/15615625");
    videoView.setMediaController(mediaController);
    videoView.setVideoURI(video);


     videoView.start();
     setContentView(R.layout.video);


    }
@SuppressLint("ParserError") @Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}


}

video.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.wunapp.newsvideoapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Screen1">

        </activity>
        <activity
            android:name=".Screen2">

        </activity>

        <activity
            android:name=".video">

        </activity>
        </application>

</manifest>

I get this logcat error as well (after implementing the changes made in the comments)

07-16 15:46:01.259: E/AndroidRuntime(15421): FATAL EXCEPTION: main
07-16 15:46:01.259: E/AndroidRuntime(15421): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wunapp.newsvideoapp/com.wunapp.newsvideoapp.Screen2}: java.lang.NullPointerException
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2240)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.ActivityThread.access$600(ActivityThread.java:139)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.os.Looper.loop(Looper.java:154)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.ActivityThread.main(ActivityThread.java:4977)
07-16 15:46:01.259: E/AndroidRuntime(15421): at java.lang.reflect.Method.invokeNative(Native Method)
07-16 15:46:01.259: E/AndroidRuntime(15421): at java.lang.reflect.Method.invoke(Method.java:511)
07-16 15:46:01.259: E/AndroidRuntime(15421): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-16 15:46:01.259: E/AndroidRuntime(15421): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-16 15:46:01.259: E/AndroidRuntime(15421): at dalvik.system.NativeStart.main(Native Method)
07-16 15:46:01.259: E/AndroidRuntime(15421): Caused by: java.lang.NullPointerException
07-16 15:46:01.259: E/AndroidRuntime(15421): at com.wunapp.newsvideoapp.Screen2.onCreate(Screen2.java:30)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.Activity.performCreate(Activity.java:4538)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
07-16 15:46:01.259: E/AndroidRuntime(15421): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-16 15:46:01.259: E/AndroidRuntime(15421): … 11 more

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:22:44+00:00Added an answer on June 7, 2026 at 9:22 pm

    When you click videoNext, you’re simply loading screen2’s xml into MainActivity.

    setContentView(R.layout.screen2xml);
    

    If you want to load Screen2 activity, then you need to launch it with an intent like the one you have commented out. That way the second activity will be shown and actually use the screen2’s xml correctly. Like this:

    Intent myIntent = new Intent(MainActivity.this, Screen2.class);
    MainActivity.this.startActivity(myIntent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an app that has three tabs on the main screen. Each
I'm creating android app that has table layout for the main activity, and that
I'm creating iOS app that has a label. I want to set two colors.
I'm creating an app that has the feature of adding two profiles/accounts. Each profile
I've started creating a Sencha Touch 2 app that has two models defined, Change
I am creating an app that alerts user if he has been stationary for
I'm creating a MonoTouch app that has some declarative business logic that the client
I am creating a custom membership provider for a web app that already has
i am creating an app which has two UIImageViews at top and bottom of
How would one go about creating an ipad app that has a similar view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.