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

  • Home
  • SEARCH
  • 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 4083434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:18:44+00:00 2026-05-20T18:18:44+00:00

EDIT: Posting full code (except XML as it a bunch of ridiculous table formatting!)

  • 0

EDIT: Posting full code (except XML as it a bunch of ridiculous table formatting!) Please ignore the code that doesn’t pertain to my question! I am just getting functionality right now. I’ll clean it up later.

First app and first question. I’ve researched here a while and usually find my answer but I have a bugger that is probably very obvious. I have an imageButton that doesn’t seem to be calling the method assigned.

My XML for my imageButton:

<ImageButton 
 android:background="@null"
 android:onClick="click" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" 
 android:id="@+id/imageButton1" 
 android:src="@drawable/stats" 
 android:layout_gravity="center_vertical">
</ImageButton>

My code:

package com.talismancs;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class sheet extends Activity{
   private String selection;
   private String pick;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.sheet);
  Bundle extras = getIntent().getExtras(); 
 
  
  if(extras !=null) {
      // Get extra from .main and remove spaces
      String pick = extras.getString(selection);
      pick = pick.replace(" ", "");
      
      //Convert extra from string to int as ID and make image
      int imageResource = getResources().getIdentifier(pick, "drawable", getPackageName());
      ImageView iv = (ImageView) findViewById(R.id.imageView1);
      final Drawable image = getResources().getDrawable(imageResource);
      iv.setImageDrawable(image);
      
      // Populate tv's from string
      TextView tv1 = (TextView) findViewById(R.id.textView4);
      TextView tv2 = (TextView) findViewById(R.id.textView5);
      TextView tv3 = (TextView) findViewById(R.id.textView6);
      TextView tv4 = (TextView) findViewById(R.id.textView7);
      TextView tv5 = (TextView) findViewById(R.id.textView8);
      int arrayresource = getResources().getIdentifier(pick, "array", getPackageName());
      String[] CharString = getResources().getStringArray(arrayresource);
      tv1.setText(CharString[0]);
      tv2.setText(CharString[1]);
      tv3.setText(CharString[2]);
      tv4.setText(CharString[3]);
      tv5.setText(CharString[4]);
    }
  
  }

public void onClick(View view) {
    Intent i = new Intent(sheet.this, stats.class);
    i.putExtra(pick, pick);
    startActivity(i);
    
}
      

}

Seems simple right? When I click the imageButton it does absolutely nothing!

Please help.

EDIT: LOGCAT After selecting a spinner item which gets us to this activity .sheet

> 03-16 06:15:38.977:
> INFO/ActivityManager(563): Displayed
> activity com.talismancs/.sheet: 766 ms
> 03-16 06:15:42.907:
> DEBUG/dalvikvm(1735): GC freed 448
> objects / 39160 bytes in 58ms 03-16
> 06:15:43.847:
> INFO/NotificationService(563):
> enqueueToast pkg=com.talismancs
> callback=android.app.ITransientNotification$Stub$Proxy@43773720
> duration=1  03-16 06:15:43.877:
> INFO/ActivityManager(563): Starting
> activity: Intent {
> comp={com.talismancs/com.talismancs.sheet} (has extras) }  03-16 06:15:43.917:
> WARN/InputManagerService(563): Window
> already focused, ignoring focus gain
> of:
> com.android.internal.view.IInputMethodClient$Stub$Proxy@43718320
> 03-16 06:15:44.527:
> INFO/ActivityManager(563): Displayed
> activity com.talismancs/.sheet: 646 ms

After that is does nothing when I click the imageButton

  • 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-20T18:18:45+00:00Added an answer on May 20, 2026 at 6:18 pm

    Your code is wrong. You havent assigned ur button with ClickListener.

    Please see this sample code for how to implement it.

    public class ExampleActivity extends Activity implements OnClickListener {
        protected void onCreate(Bundle savedValues) {
            ...
            Button button = (Button)findViewById(R.id.corky);
            button.setOnClickListener(this);
        }
    
        // Implement the OnClickListener callback
        public void onClick(View v) {
          // do something when the button is clicked
        }
        ...
    }
    

    You may visit this link for more reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HTML form POSTing to the following index.php: <?php require_once(/home/full/path/to/included/file.php); ?> And
I have data that always looks something like this: alt text http://michaelfogleman.com/static/images/chart.png I need
Posting a stack overflow question on stackoverflow.com, how amusing :-) I'm running some recursive
Imgur is a image uploading website who offers an API to upload My code
I have mod_rewrite working on most of my site. Right now I have a
I've been a PHP developer for many years now, with many tools under my
okay, so i have an asp.net (C#) application and i want to add a
I am a newbie in openID. I spend a lot of time thinking what
Ok so I need to download some web pages using Python and did a
I'm trying to track down a bug with some random characters appearing when saving

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.