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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:09:36+00:00 2026-06-12T08:09:36+00:00

Sorry that I am very new to the android development and now that I

  • 0

Sorry that I am very new to the android development and now that I would like to workout that when the user presses a button, it will initiate Actitity2, and similarly when the user press the cancel button in Activity2, it will back to the original activity.

I have referenced to the book about writing app but it seems cannot work, the coding is looks simple and as follows:

public class NameIndex extends Activity 
{
       // called when the activity is first created
       @Override
       public void onCreate(Bundle savedInstanceState) 
       {
          super.onCreate(savedInstanceState); 
          setContentView(R.layout.name_index);

           public button_cancel_click (View view) { /////// <-- ERROR AT THIS LINE
               Intent intent = new Intent (this, GameIndex.class);
               startActivity(intent);
           }
       } // end method onCreate
}

The xml layout as follows:

    <TableRow android:id="@+id/tableRow1" 
      android:layout_height="match_parent" 
      android:layout_width="match_parent"
      android:paddingBottom="10dp"
      android:paddingTop="10dp"      
      android:layout_span="2" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_span="1"
            android:layout_weight="1"
            android:onClick="button_cancel_click"            
            android:text="Cancel" />     
    </TableRow>          

The Eclipse reports the above error line as “button_cancel_click cannot be resolved to a type“, and that for

view “Illegal modifier for parameter view; only final is permitted“.

How could this be solved?

  • 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-12T08:09:37+00:00Added an answer on June 12, 2026 at 8:09 am

    you are writing the definition of button_cancel_click function in OnCreate function body correct it like this:

    public void onCreate(Bundle savedInstanceState)
    {
    .
    .
    .
    }
    public button_cancel_click (View view) 
    {
    .
    .
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to android development and I'm working on an application where I
I am very new to AS3, and I'm confused about how things that would
I am new to XNA, and I am creating a simple game. Sorry that
This question will be a little longer and I am sorry for that :)
I'm feeling very, very stupid right now... I feel like I must be missing
Sorry if the question is very elementary, I am still very new to Haskell.
Hi I'm new to android programming, I'm trying to initiate the on click method
Let me start off by saying that I am very new to WPF and
I am very new to this and i am sorry to ask this question.
I'm very new to Java, so I'm sorry if this is a bit too

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.