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 4615834
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:53:47+00:00 2026-05-22T01:53:47+00:00

I want to make a simple action in which when i press a button

  • 0

I want to make a simple action in which when i press a button then i should jump to another activity. But in this program whenever i press submit button an error is occurred and program terminated.

Please check my code and help me what error i have done.

My first activity

package login.test;

import android.app.Activity;
import android.os.Bundle;
import android.content.*;
import android.widget.*;
import android.view.View;

import android.view.View.OnClickListener;

public class login extends Activity  
{
    /** Called when the activity is first created. */
    EditText e;
    Button b;
    @Override

    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         b=(Button)findViewById(R.id.submit);
       e=(EditText)findViewById(R.id.editText1);

    b.setOnClickListener( new OnClickListener()
    {

       @Override
       public void onClick(View v)
        {
           if (v.getId() == R.id.submit) 
            {
               Intent myIntent = new Intent(v.getContext(), some.class);
               startActivityForResult(myIntent, 0);

            } 
            else
            {
                e.setText("cant go");
            }
       }
    });
    }
}

second Activity

package login.test;
import android.os.Bundle;
import android.app.Activity;
import android.content.*;
import android.widget.*;
import android.view.View;
import android.view.View.OnClickListener;

public class some extends Activity {
     public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.welcome);
        }
}

main.xml

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

<Button android:text="Submit" android:id="@+id/submit" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="EditText" android:id="@+id/editText1"></EditText>
</LinearLayout>

welcome.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">
    <EditText android:text="You are welcome" android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
</LinearLayout>
  • 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-05-22T01:53:48+00:00Added an answer on May 22, 2026 at 1:53 am

    I think you missed add your second activity in menifest..

    So plz add second activity in menifest.

    and second thing is no need to check

    if (v.getId() == R.id.submit) 
    

    because you setOnClickListener on button so v will always button.

    remove this condition

    compare my code with your..

    b.setOnClickListener( new OnClickListener()
        {
    
           @Override
           public void onClick(View v)
            {
               Intent myIntent = new Intent(login.this, some.class);
               startActivityForResult(myIntent, 0);
    
    
           }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I want to make simple toggle program (that will be mapped to some
I want to make a simple program that sends random keystrokes to my other
I want to make a simple test programm which set the color of the
I want make simple call app. I use this code. Intent intent = new
I want to make a simple service, (which will run in the background) when
I need information about making installation packages for Linux. I want to make simple
I want to make a simple app, where a UIWebView with custom content will
I want to make a simple game: 2d, single-player, without tons of animations and
I want to make a simple game so that I can play against my
I want to make a simple phylogenetic tree for a marine biology course as

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.