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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:44:56+00:00 2026-06-01T08:44:56+00:00

I have a button in my XML, that when clicked will toggle the visibility

  • 0

I have a button in my XML, that when clicked will toggle the visibility of my TableLayout. This is the XML,

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:id="@+id/LayoutAddOns"
        android:orientation="vertical" >

            <!-- Accordion button -->
            <Button
                android:id="@+id/DisplayAddOns"
                android:layout_width="335dp"
                android:layout_height="35dp"
                android:drawableLeft="@drawable/rarrow"
                android:onClick="ShowAddons"
                android:text="AddOns (Optional)" />
            <!-- Table for add ons -->
              <TableLayout
                android:id="@+id/tableAddOns"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone" >

                        <TableRow
                            android:id="@+id/tableRow1"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                             >

                            <CheckBox
                                android:id="@+id/CheckGalleryPlus"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Gallery Plus"
                                android:textSize="14sp" />

                            <CheckBox
                                android:id="@+id/CheckSubtitle"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Subtitle"
                                android:textSize="14sp" />

                        </TableRow>
                        <TableRow
                            android:id="@+id/tableRow2"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <CheckBox
                                android:id="@+id/CheckDesigner"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Designer"
                                android:textSize="14sp" />

                            <CheckBox
                                android:id="@+id/CheckSupersize"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Supersize"
                                android:textSize="14sp" />

                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <CheckBox
                                android:id="@+id/CheckScheduled"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Scheduled"
                                android:textSize="14sp" />

                            <CheckBox
                                android:id="@+id/CheckInternationalVisibility"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="International Visibility"
                                android:textSize="14sp" />                                  

                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow4"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >


                            <CheckBox
                                android:id="@+id/CheckBold"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Bold"
                                android:textSize="14sp" />

                            <CheckBox
                                android:id="@+id/CheckHighlight"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Highlight"
                                android:textSize="14sp" />                          

                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow5"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >


                            <CheckBox
                                android:id="@+id/CheckFeaturedList"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Featured List"
                                android:textSize="14sp" />

                            <CheckBox
                                android:id="@+id/CheckFeaturedPlus"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="Featured Plus"
                                android:textSize="14sp" />                          

                        </TableRow>

            </TableLayout> 

    </LinearLayout>

This is the data from LogCat,

04-03 01:21:52.891: D/AndroidRuntime(408): Shutting down VM
04-03 01:21:52.891: W/dalvikvm(408): threadid=1: thread exiting with uncaught         exception (group=0x40014760)
04-03 01:21:52.911: E/AndroidRuntime(408): FATAL EXCEPTION: main
04-03 01:21:52.911: E/AndroidRuntime(408): java.lang.IllegalStateException: Could not find a method ShowAddons(View) in the activity class toggler.state.TogglerActivity for onClick handler on view class android.widget.Button with id 'DisplayAddOns'
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.view.View$1.onClick(View.java:2670)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.view.View.performClick(View.java:3110)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.view.View$PerformClick.run(View.java:11934)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.os.Handler.handleCallback(Handler.java:587)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.os.Looper.loop(Looper.java:132)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.app.ActivityThread.main(ActivityThread.java:4123)
04-03 01:21:52.911: E/AndroidRuntime(408):  at java.lang.reflect.Method.invokeNative(Native Method)
04-03 01:21:52.911: E/AndroidRuntime(408):  at java.lang.reflect.Method.invoke(Method.java:491)
04-03 01:21:52.911: E/AndroidRuntime(408):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-03 01:21:52.911: E/AndroidRuntime(408):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-03 01:21:52.911: E/AndroidRuntime(408):  at dalvik.system.NativeStart.main(Native Method)
04-03 01:21:52.911: E/AndroidRuntime(408): Caused by: java.lang.NoSuchMethodException: ShowAddons [class android.view.View]
04-03 01:21:52.911: E/AndroidRuntime(408):  at java.lang.ClassMembers.getConstructorOrMethod(ClassMembers.java:235)
04-03 01:21:52.911: E/AndroidRuntime(408):  at java.lang.Class.getMethod(Class.java:904)
04-03 01:21:52.911: E/AndroidRuntime(408):  at android.view.View$1.onClick(View.java:2663)
04-03 01:21:52.911: E/AndroidRuntime(408):  ... 11 more

and this is the Java code,

    public void ShowAddons(){

    int TableId = R.id.tableAddOns;

    TableLayout TableVisibility = (TableLayout)findViewById(TableId);


    if(TableVisibility.getVisibility() == View.VISIBLE)
    {
        TableVisibility.setVisibility(View.GONE);
    }

    else
    {
        TableVisibility.setVisibility(View.VISIBLE);    
    }


}

It has no errors in eclipse, but when I run it, it says am error has occured and force closes the application. Thanks.

  • 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-01T08:44:58+00:00Added an answer on June 1, 2026 at 8:44 am

    Try making ShowAddOns() take a View argument, as ShowAddOns(View target), even if you don’t use the target view in the method.

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

Sidebar

Related Questions

i have this button xml, when it be will pressed, the pressed image(b) would
I have a button that when clicked will run a stored procedure on a
I have an application that can import an XML file through this terminal command
I want to have a Button that when clicked, removes all the checked items
In my layout xml file I have set the android:onClick attribute for a Button
I have a basic Android question here: I have a main.xml layout that loads
I have a page (parent) that when a button (with .click funciton) is clicked
Hiiii there, I have an xml layout and when a button is clicked I
I have MovieClips on my Flash Stage that when clicked on--they toggle ON/OFF. My
I have button, which fires an event, that deletes a record from the database.

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.