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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:11:13+00:00 2026-06-10T10:11:13+00:00

This is my xml file and as you can see it is nested many

  • 0

This is my xml file and as you can see it is nested many times by Linear layout.


What i want to acheive is when I click on the area of llOptionA(First
Linear Layout) i will get notified by a toast.


I have also put a toast on llOptionA.setonclickListener()
But when i click on the text it does nothing.

then I also set onclicklisteners on each of them giving me different toasts -> svTest ,layout_inner ,tvOptionA. and also i clicked everywhere to see which part is showing which toast.

     <LinearLayout
            android:id="@+id/llOptionA"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ff00ff"
            android:paddingLeft="30dp"
            android:paddingRight="30dp"
            android:paddingTop="5dp" >

            <HorizontalScrollView
                android:id="@+id/svTest"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <LinearLayout
                    android:id="@+id/layout_inner"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/tvOptionA"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:maxLines="1"
                        android:text="A - Option A "
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textColor="#ffffff"
                        android:textStyle="bold" />
                </LinearLayout>
            </HorizontalScrollView>
        </LinearLayout>
  • 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-10T10:11:15+00:00Added an answer on June 10, 2026 at 10:11 am

    First a LinearLayout does not listen for click events by default even when you set an OnClickListener. You also need to add this attribute to your LinearLayout llOptionA:

    android:clickable="true"
    

    Second a click starts at the highest level, TextView tvOptionA, and works it’s way down until a View consumes this event. So before it reaches llOptionA your HorizontalScrollView intercepts the click in it’s default OnTouchListener and doesn’t pass it down to your llOptionA… You can listener for a click event with an OnTouchListener in your HorizontalScrollView to call the appropriate method.

    Third perhaps this is a simplified layout, but the LinearLayout layout_inner only has one child and therefor is not necessary, you can simply use this:

    <LinearLayout ...>
        <HorizontalScrollView ...>
            <TextView .../>
        </HorizontalScrollView>
    </LinearLayout>
    

    Of course llOptionA only has one child so you could simplify it more:

    <HorizontalScrollView ...>
        <TextView .../>
    </HorizontalScrollView>
    

    Addition from comments

    Here is how to put it all together:

    public class Example extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            LinearLayout linearLayout = (LinearLayout) findViewById(R.id.llOptionA);
            linearLayout.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    toast();
                }
            });
    
            HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.svTest);
            hsv.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if(event.getAction() == MotionEvent.ACTION_UP)
                        toast();
                    return false;
                }
            });
        }
    
        public void toast() {
            Toast.makeText(this, "Click", Toast.LENGTH_SHORT).show();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I can't understand this error I want read this XML file: <?xml version=1.0
this is my XML file <atm> i want to know how can i verify
I am using an XML file to store the values. This XML file can
How can I get java classes from an xml file? In this situation, I
Can you help me to list browsers from this file http://techpatterns.com/downloads/firefox/useragentswitcher.xml into txt file,
This is my Xml file.i want to transform this xml file into another customized
this is my xml file. i want to use xslt to transfer them into
I have a xml file named socio_form_organization.xml that have two layout's. This xml file
I have transformed an XML file See this question for a complete description What
With this XML file - <Instructions> <Admin> <Instruction> Steps must be completed in order.&lt;/br&gt;

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.