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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:54:45+00:00 2026-06-14T23:54:45+00:00

I have an activity with a ListView. ListView with custom views. I add OnItemClickLIstener

  • 0

I have an activity with a ListView. ListView with custom views. I add OnItemClickLIstener to the ListView. and when i click on item, in result i see nothing.
Activity with ListView:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/silver_conv">
<FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="40dp" android:layout_alignParentTop="true" android:id="@+id/topcontainer"
        android:background="@color/black">
</FrameLayout>
<ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/chat_list" android:layout_below="@+id/topcontainer"
        android:layout_above="@+id/last_action"
        android:cacheColorHint="#00000000"
        android:layout_marginRight="2dp" android:clickable="true"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:text="last action was at time" android:id="@+id/last_action"
          android:longClickable="false"
          android:layout_centerHorizontal="true"
          android:layout_alignParentBottom="false" android:layout_above="@+id/action_container"
          android:layout_marginBottom="5dp" android:layout_alignParentLeft="false" android:layout_marginLeft="5dp"/>
<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="43dp" android:layout_alignParentBottom="true" android:id="@+id/action_container"
        android:background="@drawable/conv_botom_action_gradient">
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/send"
            android:id="@+id/send_message_btn" android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:background="@drawable/blue_button_selector" android:textColor="@color/white"
            android:layout_marginLeft="3dp" android:layout_marginTop="3dp"/>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/add_attach_btn"
            android:layout_alignParentLeft="true" android:layout_alignParentBottom="true"
            android:background="@drawable/add_attach_button_selector"
            android:layout_marginRight="2dp" android:layout_marginBottom="3dp" android:layout_marginTop="3dp"/>
    <EditText android:layout_width="40dp" android:layout_height="wrap_content" android:id="@+id/message_et"
              android:layout_toRightOf="@+id/add_attach_btn" android:layout_toLeftOf="@+id/send_message_btn"
              android:singleLine="true" android:layout_alignParentBottom="true" android:hint="Type message here"
              android:background="@drawable/message_input" android:layout_marginBottom="3dp"
              android:gravity="center_vertical" android:layout_marginTop="3dp"/>
</RelativeLayout>

View item:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" android:gravity="center_vertical|left" android:focusable="false">

<LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:background="@drawable/incoming_message"
        android:id="@+id/container" android:layout_marginTop="5dp" android:layout_marginBottom="5dp"
        android:focusable="false">
    <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content"
                 android:focusableInTouchMode="true" android:id="@+id/attach_container" android:focusable="false"/>
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="saa"
            android:id="@+id/message_text" android:textSize="17sp" android:textColor="@color/black"
            android:focusable="false"/>
</LinearLayout>
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/date" android:textColor="@color/black" android:singleLine="true" android:lines="1"
        android:maxLines="1" android:ellipsize="none" android:layout_marginLeft="5dp" android:focusable="false"/>

And finally clickListener:

private AdapterView.OnItemClickListener clickLister = new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) {
        try {
            LinearLayout container = (LinearLayout)view.findViewById(R.id.container);
            TextView message = (TextView)container.findViewById(R.id.message_text);
            message.setTextColor(mContext.getResources().getColor(R.color.white));
            Log.e("My item is", "" + pos);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
};

And here is Initialization of ListView:

mConvListView = (ListView)findViewById(R.id.chat_list);
    mConvListView.setDivider(null);
    mConvListView.setDividerHeight(0);
mConvListView.setItemsCanFocus(false);
    mConvListView.setOnItemClickListener(clickLister);
    mConvListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    mConvListView.setStackFromBottom(true);

P.s. Sorry for a lot code. But I can’t find any suggestion a second day.

  • 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-14T23:54:47+00:00Added an answer on June 14, 2026 at 11:54 pm

    By setting focusable objects in your row layout, you are preventing the ListView from getting the touch event.

    This FrameLayout is consuming the touch event:

    <FrameLayout 
        android:id="@+id/attach_container" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:focusableInTouchMode="true" 
        android:focusable="false"/>
    

    Remove the focusable settings so it looks like this:

    <FrameLayout 
        android:id="@+id/attach_container" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" />
    

    (You really should organize your XML so that is is readable, in Eclipse use Ctrl+Shift+F.)

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

Sidebar

Related Questions

I have an Activity in Android, with two elements: EditText ListView When my Activity
I have a ListView on my Android Activity. When I scroll it, the background
I have an activity with a ListView which is populated through a custom ArrayAdapter.
I have an activity with a listView, which uses a custom row layout defined
I have a problem when I want to make custom listview in android. MyListView
In my application, i have activity group in which i have a custom ListView
I have an activity with listview and attached footer. I created my custom adapter
I have an Android activity in which I have a ListView bound to a
I have a custom ListView activity that maintains a state array (3 choices, default=black,
I'm trying to launch an activity from a custom lisview. I have hoded the

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.