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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:54:43+00:00 2026-06-15T13:54:43+00:00

this problem this driving me crazy…. I have a FragmentActivity. Inside I have a

  • 0

this problem this driving me crazy….

I have a FragmentActivity. Inside I have a listView where i list some clients. I need to click in the list to do a operation. But the OnItemClickListener is not triggered. I don’t know why. I try all solutions that i view, and don’t work……

 public class MainActivity extends FragmentActivity implements OnQueryTextListener, LoaderManager.LoaderCallbacks<Cursor>, SimpleCursorAdapter.ViewBinder, OnItemClickListener{

   @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main);

    listActivos = getListView();

    cursorFiltroAutocomplete = Client.listActiveClients(this);

    cursorAdapter = new SimpleCursorAdapter(this, 
            R.layout.client_row,
            cursorFiltroAutocomplete,
            new String[]{Client.NAME,Client.ACCOUNT,Client.ICON,Client.PHOTO,Client.DATEINI,Client.DATEFIN},
            new int[]{R.id.nameClient,/*R.id.accountClient*/R.id.star,R.id.photo,R.id.dateIni,R.id.dateFim}
    );
   listActivos.setAdapter(cursorAdapter);
   cursorAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {   
        @Override
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            switch (view.getId()){
            case R.id.nameClient:
                TextView tv = (TextView)view;
                tv.setText(cursor.getString(columnIndex));
                return true;
            //case R.id.accountClient:
            //  return true;
            case R.id.star:
                star = cursor.getInt(cursor.getColumnIndex(Client.ICON));
                tbFavorite = (ToggleButton)view;
                if(star==1)
                    tbFavorite.setChecked(true);
                else
                    tbFavorite.setChecked(false);               
                return true;        
            case R.id.photo:
                byte[] bb = cursor.getBlob(cursor.getColumnIndex(Client.PHOTO));
                ImageView myImage = (ImageView)view;
                if (bb != null) {
                    myImage.setImageBitmap(BitmapFactory.decodeByteArray(bb, 0, bb.length));
                } else {
                    Bitmap bm = null;
                    try  {
                    bm = getBitmapFromAsset("contact_userUpdate.png");
                    } catch (IOException ex){ex.printStackTrace();}
                    if ( bm != null)
                        myImage.setImageBitmap(bm);
                    else 
                        Log.w(MainActivity.class.getName(), "ICON IS NULL");        
                  }
                return true;
            case R.id.dateIni:
                dateIni = cursor.getString(cursor.getColumnIndex(Client.DATEINI));
                TextView dateI = (TextView)view.findViewById(R.id.dateIni);
                dateI.setText(dateIni);
                return true;
            case R.id.dateFim:
                dateFim = cursor.getString(cursor.getColumnIndex(Client.DATEFIN));
                TextView dateF = (TextView)view.findViewById(R.id.dateFim);
                dateF.setText(dateFim);
                return true;
            }
            return false;
        }
    });
     registerForContextMenu(listActivos); 
     listActivos.setClickable(true);
     listActivos.setOnItemClickListener(this);
     getSupportLoaderManager().initLoader(0, null, this);
   }  

   /*********************************Function to get ListView************************/
   private ListView getListView() {
    return (ListView)findViewById(android.R.id.list);
}  

   /*********************************Function onItemClick*****************************/

   public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    Log.w(MainActivity.class.getName(), "ITEM CLICADO");

}

 /******************************XML with the row of the List************************/
   <?xml version="1.0" encoding="utf-8"?>

 <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:background="@android:drawable/list_selector_background"
     android:gravity="fill_horizontal"
     android:longClickable="true"
     android:clickable="true"
     android:minHeight="?android:attr/listPreferredItemHeight"
     android:paddingBottom="8dip"
     android:paddingTop="5dip">

  <ImageView
      android:id="@+id/photo"
      android:layout_width="70dp"
      android:layout_height="70dp"
      android:layout_marginLeft="20dp"
      android:layout_marginRight="10dp"
      android:scaleType="fitXY"
      android:src="@drawable/contact_user"
      android:focusable="false"
      android:clickable="false" />

  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="fill_horizontal"
      android:layout_marginLeft="10dp"
      android:layout_marginRight="10dp"
      android:layout_weight="1"
      android:gravity="fill"
      android:orientation="vertical">

    <TextView
        android:id="@+id/nameClient"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#ffffff"
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:minLines="1"
        android:maxLines="1"
        android:focusable="false"
        android:clickable="false"/>
    <LinearLayout
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="fill_horizontal"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_weight="1"
        android:gravity="fill" 
        android:orientation="horizontal">

        <TextView android:id="@+id/dateIni"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="@string/dateIni"
                  android:textColor="#59df8f"
                  android:textAppearance="?android:attr/textAppearanceMedium"
                  android:minLines="1"
                  android:maxLines="1"
                  android:focusable="false"
                  android:clickable="false" />

        <TextView android:id="@+id/dateFim"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="@string/dateFim"
                  android:textColor="#ff3100"
                  android:textAppearance="?android:attr/textAppearanceMedium"
                  android:minLines="1"
                  android:maxLines="1"
                  android:focusable="false"
                  android:clickable="false"/>
      </LinearLayout>           
  </LinearLayout>
        <ToggleButton
            android:id="@+id/star"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="20dp"
            android:background="@drawable/list_star_selector"
            android:focusable="false"
            android:clickable="false"/>
     </TableRow>

   /******************************XML with the list View******************************/
     <?xml version="1.0" encoding="utf-8"?>

   <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:background="@drawable/background_tile"
     android:orientation="vertical" >

  <ListView 
      android:id="@+id/@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:clickable="true"
      />
   </LinearLayout>

Anyone have an idea? I put the item’s of the list “android:focusable=”false” but don’t work. I put android:descendantFocusability=”beforeDescendants” but the result is the same….

  • 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-15T13:54:44+00:00Added an answer on June 15, 2026 at 1:54 pm

    Try it out with setting focusable=false on your TableRow:

     <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:background="@android:drawable/list_selector_background"
             android:gravity="fill_horizontal"
             android:longClickable="true"
             android:clickable="true"
             android:minHeight="?android:attr/listPreferredItemHeight"
             android:paddingBottom="8dip"
             android:focusable="false"      // try this
             android:paddingTop="5dip">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is driving me crazy, I'm sure I'm missing something. I need to
I have this problem driving me crazy. I have spent decades to figure it
This problem is driving me crazy. I have the following code: 'unprotect sheet If.Range(Start).Row+1<.Range(End).Row
This is NOT a duplicate question, and the problem is driving me crazy. I
Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning
I have a really weird problem that is driving me crazy. I have a
This is driving me crazy! I have read at least 5 questions on here
This problem is driving me a bit crazy. The code seems to be segmentation
I know this a basic problem but it is still driving me crazy. I
this is driving me crazy. I have a piece of code on a Windows

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.