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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:09:25+00:00 2026-05-24T07:09:25+00:00

I am having a silly problem with a OnItemCliskListener for my ListView. It works

  • 0

I am having a silly problem with a OnItemCliskListener for my ListView. It works well when the XML is very simple but after I improve its complexity, the OnItemCliskListener stop working

In other words, I have a ListView with just a TextView. But if I turn my ListView into a more complex list with other TextView, an Icon a CheckBox, the ClickListener stop working.

If I run exactly the same code changing just the XML, the OnItemCliskListener stops working. I would be rather grateful if you could help me

WORKING LIST VIEW:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:orientation="vertical"
    android:layout_height="fill_parent">
    <TextView android:id="@+id/title"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:layout_toLeftOf="@+id/appCheck"
        android:layout_toRightOf="@+id/appIcon"
        android:textAppearance="?android:attr/textAppearanceLarge">
    </TextView>
</RelativeLayout>

NOT WORKING LISTVIEW:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:orientation="vertical"
    android:layout_height="fill_parent">
    <ImageView android:src="@drawable/icon" android:id="@+id/appIcon"
        android:layout_width="30px" android:layout_height="40px"></ImageView>
    <CheckBox android:id="@+id/appCheck"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:layout_alignParentRight="true"></CheckBox>
    <TextView android:id="@+id/title"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:layout_toLeftOf="@+id/appCheck"
        android:layout_toRightOf="@+id/appIcon"
        android:textAppearance="?android:attr/textAppearanceLarge">
    </TextView>
    <TextView android:id="@+id/subtitle"
        android:layout_height="wrap_content" android:layout_width="wrap_content"
        android:layout_toLeftOf="@+id/appCheck"
        android:layout_toRightOf="@+id/appIcon" android:layout_below="@+id/title"
        android:textAppearance="?android:attr/textAppearanceSmall">
    </TextView>
</RelativeLayout>

MY JAVA ACTIVITY:

public class MyTabsActivity extends TabActivity implements OnTabChangeListener {
private static final String LIST3_TAB_TAG = "List3";

private RelativeLayout layoutTab3;      
private MyArrayAdapter adapterListViewTab3;
private TabHost tabHost;
...
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            tabHost = getTabHost();
            tabHost.setOnTabChangedListener(this);
...
...
// ----------------- BUILD TAB3
            // That is my Tab of Running App
            layoutTab3 = (RelativeLayout) findViewById(R.id.running_app_relative_layout);
            // Fill my ListView of Running App
            ListView runningAppList = (ListView) findViewById(R.id.running_app_listview);
            List<String> list3Strings = new ArrayList<String>();
            list3Strings.add("Item 1");
            list3Strings.add("Item 2");
            list3Strings.add("Item 3");
            list3Strings.add("Item 

            adapterListViewTab3 = new MyArrayAdapter(this, android.R.layout.simple_list_item_1, list3Strings);
            runningAppList.setAdapter(adapterListViewTab3);
            // ????????????????????????????????????????????????????????????????????????????????????????????
            // >>>>>>>>>>>> THIS OnItemClickAdapter DOESN'T WORK !!!!! WHY ????????
            runningAppList.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                        int position, long id) {
                    Toast.makeText(MyTabsActivity.this, "EUREKA", Toast.LENGTH_SHORT).show();
                }
            });

...
// add Tab3
            TabSpec tab3 = tabHost.newTabSpec(LIST3_TAB_TAG).setIndicator(LIST3_TAB_TAG).setContent(new TabContentFactory() {
                public View createTabContent(String arg0) {
                    return layoutTab3;
                }
            });
            tabHost.addTab(tab3);
            layoutTab3.setVisibility(View.INVISIBLE);
...
}
}

MY R.layout.main:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent" android:layout_height="wrap_content" />
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent" android:layout_height="fill_parent">

            <ListView android:id="@+id/list1" android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:layout_weight="1">
            </ListView>

            <ListView android:id="@+id/list2" android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:layout_weight="1">
            </ListView>

            <RelativeLayout android:id="@+id/running_app_relative_layout"
                android:orientation="vertical" android:layout_width="fill_parent"
                android:layout_height="fill_parent">

                <LinearLayout android:orientation="horizontal"
                    android:id="@+id/coco" android:layout_alignParentTop="true"
                    android:layout_width="fill_parent" android:layout_height="fill_parent">
                    <ListView android:id="@+id/running_app_listview"
                        android:scrollbars="vertical" android:layout_width="fill_parent"
                        android:layout_height="wrap_content" android:layout_gravity="fill_vertical"
                        android:layout_alignParentTop="true"></ListView>
                </LinearLayout>
            </RelativeLayout>

        </FrameLayout>
    </LinearLayout>
</TabHost>
  • 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-24T07:09:26+00:00Added an answer on May 24, 2026 at 7:09 am

    I’ve figured out that when a custom ListView contains focusable elements, onListItemClick won’t work (I think it’s the expected behaviour). So I’ve just removed the focus from the custom view and it did the trick. In other words, I added the following commands to my view:

    android:focusable="false"
    android:focusableInTouchMode="false"
    

    The full explanation is avaiable here: How to fire onListItemClick in Listactivity with buttons in list?

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

Sidebar

Related Questions

This is almost certainly a very silly question, but for some reason I'm having
Hopefully my issue isn't too silly but I'm having the following problem... I'm importing
Possibly a silly question, but I'm having no luck finding an answer. Using Visual
Ok this seems so silly but I'm having some trouble getting this to work.
Kick me if I'm being silly but some some reason I'm having a heck
Guys I know this question is silly but just to make sure: Having in
I'm new to Moq, and having what seems to be a silly problem. If
Well been working for hours today so i might be missing something silly, but,
Ok, this might sound like a silly question, but I'm having all sorts of
I'm having a seemingly silly problem with my gcc compiler. I have installed MinGW

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.