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

  • Home
  • SEARCH
  • 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 8122291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:47:24+00:00 2026-06-06T05:47:24+00:00

I have a listview : <ListView android:clickable=true android:id=@android:id/list android:layout_width=match_parent android:layout_height=wrap_content > </ListView> the elements

  • 0

I have a listview:

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

the elements that go inside it are like this:

<?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:orientation="horizontal" >




    <TextView
        android:id="@+id/textview_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.76"
        android:text="Choose"
        android:clickable="true" />


    <EditText
        android:id="@+id/edittext_share"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.12"
        android:ems="10"
        android:hint="share"
        android:inputType="number" >

        <requestFocus />
    </EditText>


    <EditText
        android:id="@+id/edittext_spent"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.11"
        android:ems="10"
        android:hint="spent"
        android:inputType="number" />

</LinearLayout>

I want that when I click on the TextView, something should happen. I have set the setOnItemClickListener via the getListView() but it does not work.

    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    // TODO Auto-generated method stub
    Toast.makeText(this,"clicked id="+arg2, Toast.LENGTH_SHORT).show();
}

and

        ListView lv = getListView();
    lv.setOnItemClickListener(this);

What do I do to make the textview clicable?

EDIT: my adapter code:

    private class PeopleListAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    public Cursor cursor;
    public ArrayList<PersonInfo> peopleList;
    public ArrayList<PersonInfo> unsavedPeopleList;

    public PeopleListAdapter(Context context, Cursor cursor) {
        // Cache the LayoutInflate to avoid asking for a new one each time.
        mInflater = LayoutInflater.from(context);
        this.cursor = cursor;
        peopleList = new ArrayList<PersonInfo>(cursor.getCount());
    }

    public PeopleListAdapter(Context context, Cursor cursor,
            ArrayList<PersonInfo> unsavedList) {
        this(context, cursor);
        this.unsavedPeopleList = unsavedList;
    }

    /**
     * The number of items in the list is determined by the number of
     * speeches in our array.
     * 
     * @see android.widget.ListAdapter#getCount()
     */
    public int getCount() {
        return peopleList.size() + unsavedPeopleList.size();
    }

    /**
     * Since the data comes from an array, just returning the index is
     * sufficent to get at the data. If we were using a more complex data
     * structure, we would return whatever object represents one row in the
     * list.
     * 
     * @see android.widget.ListAdapter#getItem(int)
     */
    public Object getItem(int position) {

        return position;
    }


    /**
     * Use the array index as a unique id.
     * 
     * @see android.widget.ListAdapter#getItemId(int)
     */
    public long getItemId(int position) {
        return position;
    }

    /**
     * Make a view to hold each row.
     * 
     * @see android.widget.ListAdapter#getView(int, android.view.View,
     *      android.view.ViewGroup)
     */
    public View getView(int position, View convertView, ViewGroup parent) {
        // A ViewHolder keeps references to children views to avoid
        // unneccessary calls
        // to findViewById() on each row.
        ViewHolder holder;

        // When convertView is not null, we can reuse it directly, there is
        // no need
        // to reinflate it. We only inflate a new View when the convertView
        // supplied
        // by ListView is null.
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.list_item_person_info,
                    null);

            // Creates a ViewHolder and store references to the two children
            // views
            // we want to bind data to.
            holder = new ViewHolder();
            holder.name = (TextView) convertView
                    .findViewById(R.id.textview_name);
            holder.share = (EditText) convertView
                    .findViewById(R.id.edittext_share);
            holder.spent = (EditText) convertView
                    .findViewById(R.id.edittext_spent);
            convertView.setTag(holder);

        } else {
            // Get the ViewHolder back to get fast access to the TextView
            // and the ImageView.
            holder = (ViewHolder) convertView.getTag();
        }

        // Bind the data efficiently with the holder.
        PersonInfo p = getPersonInfo(position);
        holder.name.setText(p.name);
        holder.name.setTag(p.lookupUri);
        holder.share.setText(p.share + "");
        holder.spent.setText(p.spent + "");

        return convertView;
    }

    PersonInfo getPersonInfo(int position) {
        if (position < peopleList.size()) {
            PersonInfo pInfo = peopleList.get(position);
            if (pInfo == null) {
                pInfo = new PersonInfo();
                cursor.moveToPosition(position);
                pInfo.lookupUri = Uri.parse(cursor.getString(0));
                Cursor c = NewEventActivity.this.getContentResolver()
                        .query(pInfo.lookupUri,
                                new String[] { Contacts._ID,
                                        Contacts.DISPLAY_NAME }, null,
                                null, null);
                pInfo.share = cursor.getInt(1);
                pInfo.spent = cursor.getInt(2);
                try {
                    if (c.moveToFirst()) {
                        pInfo.name = c.getString(1);
                    }
                } finally {
                    cursor.close();
                }
                peopleList.set(position, pInfo);

            }

            return pInfo;
        } else {
            return unsavedPeopleList.get(position - peopleList.size());
        }
    }
  • 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-06T05:47:26+00:00Added an answer on June 6, 2026 at 5:47 am

    You need to set the Click listener Listener to TextView in Adapter in getView() function ……

    see this link

            private class PeopleListAdapter extends BaseAdapter implements
    OnClickListener {
    
         ..............................
          ............................
    
    
    public View getView(int position, View convertView, ViewGroup parent) {
           
                 ......................
               .....................
            holder.name.setText(p.name);
            //holder.name.setTag(p.lookupUri);
            holder.share.setText(p.share + "");
            holder.spent.setText(p.spent + "");
    
            holder.name.setOnClickListener(this);
           holder.name.setTag(position);
    
    
    
            return convertView;
        }
    
         @Override
        public void onClick(View v) {
            Log.d("Sample", "Clicked on tag: " + v.getTag());
            ////get PersonInfo using getPersonInfo(position) 
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML, I have the following <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=fill_parent > </ListView> How
I have a simple list with a listselector like so. <ListView android:id=@+id/list android:layout_width=fill_parent android:layout_height=fill_parent
I have a ListView ( my_list.xml ): <ListView android:id=@+id/my_list android:layout_width=wrap_content android:layout_height=wrap_content android:choiceMode=singleChoice /> The
I have this Listview element: <ListView android:id=@+id/category_list android:layout_width=fill_parent android:layout_height=fill_parent android:layout_weight=1 android:background=@drawable/list_background android:layout_marginTop=10sp android:layout_marginLeft=10sp android:layout_marginRight=10sp
It seems that android has enforced that a listview must have the name android:id=@android:id/list,
I have the following ClickListener: itemList=(ListView)findViewById(android.R.id.list); itemList.setTextFilterEnabled(true); itemList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?>
I have an android listview filled with items. Every item has a button. This
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have three ListView widgets in the same LinearLayout . Something like this (I'm

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.