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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:30:36+00:00 2026-06-18T02:30:36+00:00

I was trying to make a custom ListView . The ListView contains a RelativeLayout

  • 0

I was trying to make a custom ListView. The ListView contains a RelativeLayout who contains a TextView and a Switch. When you press on the Switch the Switch have to change from true to false (and vice versa).

This is my getView method:

public View getView(int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    if (convertView == null)
        vi = inflater.inflate(R.layout.item_gproblem, null);

    //vi.setClickable(true); Tried this
    //vi.setFocusable(true);

    TextView txt_comment_description = (TextView) vi
            .findViewById(R.id.txt_comment_description);
    txt_comment_description.setText(MyTasks.allGComments.get(position)
            .getProblemDescription());
    //txt_comment_description.setFocusable(false); Tried this
    //txt_comment_description.setClickable(false);

    Switch switch_comment = (Switch) vi.findViewById(R.id.switch_comment);
    //switch_comment.setFocusable(false); Tried this
    //switch_comment.setClickable(false);

    //First time running getMyGComments returns a empty ArrayList
    if (MyTasks.allCustomers.get(ServerData.myID - 1).getMyGComments()
            .size() > position) {
        switch_comment.setChecked(MyTasks.allCustomers
                .get(ServerData.myID - 1).getMyGComments().get(position)
                .isProblemValue());
    }
    return vi;
}

This is my onClickListener:

list_quality.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

               //Do Something
            }
        });

My onItemClickListener isn’t called when I click on the TextView, Switch or on the space between the two objects. When I hit the switch the switch acts normally (the state changes). But my onItemClickListener isn’t called. I tried to disabled clickable and focusable of the Switch and the TextView but that doesn’t work either.

The setOnItemClickListeren is executed.

  • 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-18T02:30:38+00:00Added an answer on June 18, 2026 at 2:30 am

    Add the line below to the listview row’s container:

    android:descendantFocusability="blocksDescendants"
    

    Remove all clickables/focusables from wherever you put them. Then the onItemClick should be called if you press on the whole item.

    Also, if you would like to have buttons inside the listview row clickable as well, add an onClickListener to the button inside your ListView adapter getView() method.

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

Sidebar

Related Questions

I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I am trying to make Custom RelativeLayout which can scale and scroll. Right now
I'm trying to make a custom view in Django admin. I'm reading from this
I'm trying to make a custom infowindow. Version = 2. I have added my
I'm trying to make a custom converter that inherits from DependencyObject , but it
I am trying to make a listview which has a textview and an imageview
Well I'm trying to make a ListView with images and text. I have been
I am trying to make a listview, every row contains an imageview and two
I'm trying to make listView with custom adapter and multiselection. My adapter looks like
I am starting out on Android and trying to make a custom ListView layout.

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.