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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:05:29+00:00 2026-05-24T04:05:29+00:00

Cant figure this out (am a noob) but I have a default activity that

  • 0

Cant figure this out (am a noob) but I have a default activity that starts with just one image button, clicking that image button opens the second activity that contains a bunch of image buttons but only one has an onclick, this is the exact code:

<ImageButton android:src="@drawable/level1" 
                android:layout_width="wrap_content" android:id="@+id/imageButton1" 
                android:layout_height="wrap_content" 
                android:onClick="button_clicked1">
            </ImageButton>

in the java file this is my code:

public void button_clicked1(View v) {
    //text1.setText("clicked");
    //ib2.setImageResource(R.drawable.level5);
    }

The screwy part, if that above function is empty nothing happens but no matter what I put in the above function… for example even a simple settext like the above commented one, and it force closes on me :((

the full java file if you are interested: http://pastebin.com/W4sJUKXH
and the manifest file (as the problem might be there, like I said, am a noobie) http://pastebin.com/yEuG1su7

** Where i think the error is:
In the manifest file I only have declared the second activity, nothing else…

  • 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-24T04:05:30+00:00Added an answer on May 24, 2026 at 4:05 am

    Set id for the ImageViews, this is how you handle many Buttons with one method

    public void button_clicked1(View v) {
    
        switch(v.getId())
        {
          case R.id.myfirstimage:
             //do something
            break;
         case R.id.mysecondimage:
           // do something
          break;
    
      // add more cases
    
    
         default:
           // do something if none of the cases is your image view or do nothing
        }
    
        }
    

    Set setContentView( ) before you do anything with the UI components. (Thats why you get some Exception)

     @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.start_levels_screen);
            text1 = (TextView) findViewById(R.id.textView1);
            ib2 = (ImageButton) findViewById(R.id.imageButton2);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this (noob?) question, but i just can't figure it out for many
hey guys having this really simple problem but cant seem to figure out have
Newbie question here but for some reason I cant figure this out. I have
I cant figure this one out... I have tried to use FluentNhibernate with SQLCE4..
I want to do something but cant figure out how to do this (i
I am getting segmentation fault in this code but i cant figure out why.
This seems in my head like it should work but I cant figure out
This is probably a noob question but I've been trying to figure it out
simple question i think, but cant figure this out How can I wrap particular
Hi sorry for repeating this question but i cant figure out what am i

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.