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

The Archive Base Latest Questions

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

I’ve created a somewhat simple layout with a total of 4 buttons: 3 buttons

  • 0

I’ve created a somewhat simple layout with a total of 4 buttons: 3 buttons at the bottom of the layout are side by side (in a RelativeLayout) and on huge button almost in the middle of the screen.

On Ice Cream Sandwich and Jellybean, I can click any of the buttons and everything works fine (i.e.The respective onClick functions are called) but weirdly enough on Gingerbread any of the 3 buttons at the bottom work but not the one in the middle. onClick fires off many instructions, none of which are being executed so as far as I can tell, it’s not being called and I don’t know why.

Code for layout is given below. Any help is greatly appreciated!

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_off"
android:orientation="vertical"
android:weightSum="10" >

    <ImageButton
        android:id="@+id/button_activate"
        android:layout_width="155dp"
        android:layout_height="0dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="170dp"
        android:layout_weight="7.2"
        android:background="@drawable/transparent"
        android:clickable="true"
        android:contentDescription="@string/app_name"
        android:onClick="activate"
        android:src="@drawable/transparent" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="30dp"
        android:layout_marginTop="80dp"
        android:layout_weight="2" >

        <ImageButton
            android:id="@+id/button_help"
            android:layout_width="90dp"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="0dp"
            android:background="@drawable/transparent"
            android:clickable="true"
            android:contentDescription="@string/app_name"
            android:onClick="openhelp"
            android:src="@drawable/transparent" />


        <ImageButton
            android:id="@+id/button_settings"
            android:layout_width="55dp"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="0dp"
            android:layout_toLeftOf="@+id/button_help"
            android:background="@drawable/transparent"
            android:clickable="true"
            android:contentDescription="@string/app_name"
            android:onClick="opensettings"
            android:src="@drawable/transparent" />


        <ImageButton
            android:id="@+id/button_contact"
            android:layout_width="70dp"
            android:layout_height="fill_parent"
            android:layout_alignParentRight="true"
            android:layout_marginTop="0dp"
            android:layout_toRightOf="@+id/button_help"
            android:background="@drawable/transparent"
            android:clickable="true"
            android:contentDescription="@string/app_name"
            android:onClick="opencontact"
            android:src="@drawable/transparent" />

    </RelativeLayout>

</LinearLayout>

Activity that calls the layout (main.xml):

//bunch of imports

public class MainActivity extends Activity {

@Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);

    boolean serviceOn = isMyServiceRunning();

    if(serviceOn==true) layout.setBackgroundResource(R.drawable.main_on);
    else if (serviceOn==false) layout.setBackgroundResource(R.drawable.main_off); 
}

@Override
protected void onResume() {
    super.onResume();
    LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);

    boolean serviceIsOn = isMyServiceRunning();

    if(serviceIsOn==true) layout.setBackgroundResource(R.drawable.main_on);
    else if (serviceIsOn==false) layout.setBackgroundResource(R.drawable.main_off);
}



public void activate(View v){
    LinearLayout layout = (LinearLayout) findViewById (R.id.main_layout);
    Resources res = getResources();

    Drawable on = res.getDrawable(R.drawable.main_on);
    Drawable off = res.getDrawable(R.drawable.main_off);

    if (layout.getBackground().getConstantState() == off.getConstantState()){
        layout.setBackgroundResource(R.drawable.main_on);
        Toast.makeText(getApplicationContext(), "App has been activated", Toast.LENGTH_SHORT).show();
        turnon();
    }
    else if (layout.getBackground().getConstantState() == on.getConstantState()){
        layout.setBackgroundResource(R.drawable.main_off);
        Toast.makeText(getApplicationContext(), "App has been deactivated", Toast.LENGTH_SHORT).show();
        turnoff();
    }
}

}
  • 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-12T23:51:37+00:00Added an answer on June 12, 2026 at 11:51 pm

    I can run this fine on my emulator for both 2.2 and 2.3.

    The only thing I can suggest is to try to remove drawables (maybe some settings there are screwing things up), or try to make your relative layout height 0dp, since you are using weight_sum

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is

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.