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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:48:07+00:00 2026-06-19T04:48:07+00:00

Hi I need help with active buttons in listview row. Idea is then i

  • 0

Hi I need help with active buttons in listview row. Idea is then i pressed button in the row it change textview. This list row must be avtivated in setOnItemLongClickListener();
Can anyone show me example or tutorial how make something like this or some example or show there is my problem? I tired for google it and wont get answer… I new in android and sorry for my language and tnx for any help 😉
my Idea.

+-----------------------------------------+
| textview | textview | textview | Button |
+----------+----------+----------+--------+
| textview | textview | textview | Button |
+-----------------------------------------+

Then button pressed textview become number like this:

+-----------------------------------------+
| textview | textview | textview | Button |
+----------+----------+----------+--------+
| textview | textview |     1    | Button | <- this button was pressed
+-----------------------------------------+

I made then button change it but problem is it change more rows. Like

+-----------------------------------------+
| textview | textview | textview | Button |
+----------+----------+----------+--------+
| textview | textview |     1    | Button | <- this button was pressed
+-----------------------------------------+
| textview | textview | textview | Button |
+----------+----------+----------+--------+
| textview | textview |     1    | Button | <- this button was **not** pressed
+----------+----------+----------+--------+
| textview | textview | textview | Button |
+----------+----------+----------+--------+
| textview | textview |     1    | Button | <- this button was **not** pressed
+-----------------------------------------+

I’m using SimpleAdapter to get list.

ListView lv = getListView();   
lv.setOnItemLongClickListener(listener);

OnItemLongClickListener listener = new OnItemLongClickListener() {
    public boolean onItemLongClick(AdapterView<?> parent, final View view, int position, long id) {
        btn1 = (Button) view.findViewById(R.id.button1);
        btn1.setOnClickListener(new OnClickListener(){
            int number= 0;
            public void onClick(View v) {
                // TODO Auto-generated method stub
                TextView textView = (TextView) v.findViewById(R.id.textView_must_be_changed);
                number++;
                textView.setText(String.valueOf(number)); 
            }                   
        });
    }
};

My Layout XML is

  <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:id="@+id/gridas"
      android:layout_height="fill_parent"
      android:choiceMode="multipleChoice"
      android:columnCount="10"
      android:descendantFocusability="beforeDescendants" >


      <TextView
          android:id="@+id/Textview"
          android:layout_column="5"
          android:layout_columnSpan="3"
          android:layout_gravity="left|bottom"
          android:layout_row="1"
          android:layout_rowSpan="2"
          android:text="4.3 kg" />

      <TextView
          android:id="@+id/Textview"
          android:layout_column="7"
          android:layout_gravity="left"
          android:layout_row="1"
          android:layout_rowSpan="2"
          android:text="35 cm" />



      <TextView
          android:id="@+id/Textview"
          android:layout_width="163dp"
          android:layout_height="49dp"
          android:layout_column="9"
          android:layout_gravity="left"
          android:layout_row="2"
          android:gravity="left"
          android:text="949.00 Lt"
          android:textSize="32sp"
          android:textStyle="bold" />



      <TextView
          android:id="@+id/**textView_must_be_changed**"
          android:layout_column="9"
          android:layout_gravity="left|top"
          android:layout_row="1"
          android:text="tekstukas"
           />

      <Button
          android:id="@+id/button1"
          android:layout_column="9"
          android:layout_gravity="left|top"
          android:layout_row="3"
          android:text="Button" 
          android:focusable="false"
          android:focusableInTouchMode="false"/>

  </GridLayout>    
  • 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-19T04:48:09+00:00Added an answer on June 19, 2026 at 4:48 am

    you need to create custom adapter for your list view. And in getView() method of this adapter your should set on click listener for button. This listener will call when you’ve pressed row button. And in this listener you have to get row data which you will change. Mm.. I think you should get it from tag of view, which in parametor of onClick of your listener. And also you should set this tag. In following example I show how..

    @Override
        public View getView( int position, View convertView, ViewGroup parent ){
            PhoneContactListItem item = getItem( position );
            TextView contactName;
            TextView contactPhone;
            CheckBox isCheckedCheckBox;
    
            if( convertView == null ) {
                convertView = LayoutInflater.from( context).inflate( R.layout.project_contact_list_item_layout, null );
                contactName = (TextView) convertView.findViewById( R.id.projectContactRow_contactName );
                contactPhone = (TextView) convertView.findViewById( R.id.projectContactRow_contactPhone );
                isCheckedCheckBox = (CheckBox) convertView.findViewById( R.id.projectContactRow_checkBox );
    
                convertView.setTag( new ViewHolder( contactName, contactPhone, isCheckedCheckBox ) );
    
                //setting on click listener for isCheckedCheckBox
                isCheckedCheckBox.setOnClickListener( new OnClickListener() {
                    public void onClick(View v) {
                        CheckBox cb = (CheckBox)v;
                        PhoneContactListItem i = (PhoneContactListItem)cb.getTag();
                        i.toggleChecked();
                        cb.setChecked( i.isChecked() );
                    }               
                });
            } else {
                ViewHolder vh = (ViewHolder)convertView.getTag();
                contactName = vh.getContactName();
                contactPhone = vh.getContactPhone();
                isCheckedCheckBox = vh.getIsCheckedCheckBox();
            }
    
            //initializing views
            isCheckedCheckBox.setTag( item );
            contactName.setText( item.getPhoneContact().getContactName() );
            contactPhone.setText( item.getPhoneContact().getContactPhone() );
    
            //initializing checkbox
            if( item.isChecked() )
                isCheckedCheckBox.setChecked( true );
            else 
                isCheckedCheckBox.setChecked( false );
    
            //enabling or disabling check box
            if( item.isCheckDisabled() ) 
                isCheckedCheckBox.setClickable( false );
            else 
                isCheckedCheckBox.setClickable( true );
    
            //showing checkboxes
            if( showCheckBoxes ) 
                isCheckedCheckBox.setVisibility( View.VISIBLE );
            else 
                isCheckedCheckBox.setVisibility( View.GONE );
    
            return convertView;
        }
    
        private class ViewHolder {
            private TextView contactName;
            private TextView contactPhone;
            private CheckBox isCheckedCheckBox;
    
            public ViewHolder( TextView contactName, TextView contactPhone, CheckBox isCheckedCheckBox ) {
                this.contactName = contactName;
                this.contactPhone = contactPhone;
                this.isCheckedCheckBox = isCheckedCheckBox;
            }
    
            /*
             * getters
             */
            public TextView getContactName() {
                return contactName;
            }
            public TextView getContactPhone() {
                return contactPhone;
            }
            public CheckBox getIsCheckedCheckBox() {
                return isCheckedCheckBox;
            }
        }
    

    it’s not your situation but the same..

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

Sidebar

Related Questions

Need help writing a script downloads data from google insight using c# this is
I need help with one ajax function This is raw page setup. Page will
I am beginner on WPF and need your help. Problem: I have 4 buttons
I need an active link added to the actual a link on this accordion..
I need help with this code: $mdl = Doctrine_Query::create() ->update('Model_CoachsTownsLang ctl') ->set('ctl.Coachs_Users_id', '1') ->set('ctl.Towns_idTowns',
I need help with drawing something like this: I have been told that the
I need a button to stay active after I clicked it (opacity changed). How
I need help with a MySQL query. This example is much simpler than the
This is my buttons: <button id=add>Add</button> <button id=remove>Remove</button> this is my JavaScript code: <script
I need help with a writing a OSGI module. This is the code that

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.