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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:30:13+00:00 2026-05-24T03:30:13+00:00

Here is my problem. I setup the buttons exactly the way they are setup

  • 0

Here is my problem. I setup the buttons exactly the way they are setup in the Android documentation, but I am getting a warning, and the button will not do anything.

Here is my Java code:

package com.variDice;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;

public class VariDiceActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //die1Clicked();
    }

    private void die1Clicked() {
        ImageButton die1button = (ImageButton)findViewById(R.id.die1button);
        die1button.setImageResource(R.drawable.icon);
    }
}

…and the XML:

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

    <ImageView 
        android:id="@+id/varidice_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:src="@drawable/icon"></ImageView>
    <ImageButton
        android:id="@+id/die1button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:background="@null"></ImageButton>

</LinearLayout>

…and the warning:

The method die1Clicked from the type VariDiceActivity is never used locally.

I must say that I am completely new to Android development. I made my app for the iPhone, and I am now trying to make a version for the android. The iPhone version was sooo much easier, because of the better interface builder (so I can just make an action and connect it to the button that way), so this is almost impossibly hard for me to understand. In other words, I do not understand how you connect an action to the button. Could somebody please tell me what I am doing wrong?

  • 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-24T03:30:15+00:00Added an answer on May 24, 2026 at 3:30 am

    Try this in your xml:

    <ImageButton
        android:id="@+id/die1button"
        android:onClick="die1Clicked"
        ...></ImageButton>
    

    And in your code, change the method signature to:

    public void die1Clicked(android.view.View v) {
        ImageButton die1button = (ImageButton)findViewById(R.id.die1button);
        die1button.setImageResource(R.drawable.icon);
    }
    

    Here is the Android Button tutorial.

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

Sidebar

Related Questions

This problem has been solved thanks to your suggestions. See the bottom for details.
Setup I have an accordion layout containing a properties panel that nests two inner
I'm trying to setup a search page which performs two separate kinds of search
On my website I have it setup where when someone clicks on one of
I'm almost completed moving my first live site to my new xampp setup on
I'm using the ICommand interface to perform binding on a couple of buttons in
Ok, I have code that is working (posted after this) but before I expand
I am trying to build a webservice that manipulates http requests POST and GET.
I am try to use JQuery UI Dialog to replace the ugly javascript:alert() box.
I am trying to create a window to act as a switch board for

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.