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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:56:27+00:00 2026-06-08T21:56:27+00:00

Hi hoping someone can help. I have a list view that displays various textviews,editviews

  • 0

Hi hoping someone can help. I have a list view that displays various textviews,editviews and abutton on each row. I have used the getView

     public View getView(final int position, View convertView, ViewGroup parent) 
    {            
        View v = convertView;


           if (v == null) {
                LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = inflater.inflate(R.layout.catlistrow, null);

           }

           TextView pDesc = (TextView) v.findViewById(R.id.productlinerow);
           TextView pPack = (TextView) v.findViewById(R.id.productlinerow3);
           ImageView iThumbnail = (ImageView) v.findViewById(R.id.Thumbnail);
           final Button bAdd = (Button)v.findViewById(R.id.SOCatLine);

            final EditText pOrdQty = (EditText) v.findViewById(R.id.SOQty);


           pDesc.setText(((HashMap<String,String>) getItem(position)).get("Column2")); 
           pPack.setText(((HashMap<String,String>) getItem(position)).get("Column3"));
           pOrdQty.setText(((HashMap<String,String>) getItem(position)).get("OrdQty"));
           String EanCode = ((HashMap<String,String>) getItem(position)).get("EANCode");

I then add a OnClickListner for the add button with in the getView

                bAdd.setOnClickListener(new View.OnClickListener(){          
        public void onClick(View v) {


            Object o = list.get(position);
            HashMap<String, String> map2 = (HashMap<String, String>)o;
            String b = map2.get("OrdQty");
            String sProdCode = map2.get("ProdCode");
            String ProdPrice = map2.get("ProdPrice");
            b = pOrdQty.getText().toString();

            int OrderQty = Integer.parseInt(b);

            //Check to see if add is pressed and qty zero
            if ( OrderQty == 0 )
            {
              OrderQty = 1;
              b = "1";

            }

            db.open();
            int iOrderNo = Integer.parseInt(OrderNo);


            // update line
            iLineNumber = iLineNumber + 1;
            int QtyCheck = db.createCATorderline(iOrderNo, iLineNumber,
                            sProdCode, ProdPrice, b,"P");


            bAdd.setText("Change"); 


            //Close the database
            db.close();



        }   

  }); 

The button text changes fine on the button i clicked on which is great. The problem im having is that if i scroll down every now and then i see the text has also changed on one of the buttons on the screen.

Can anyone help?

Thanks Neil

XML for the list view

 <ImageView
android:id="@+id/Thumbnail"
android:layout_width="190px"
android:layout_height="200px"
android:layout_alignParentLeft="true"
android:maxWidth="190px"
android:maxHeight="200px"
android:background="@null" />

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/productlinerow"
 android:textColor="#000000" 
 android:layout_marginTop="10dip"
 android:textSize="25dip"
 android:layout_marginBottom="20dip"
 android:layout_height="match_parent" 
 android:text="column1"
 android:layout_width="400dip" 
 android:layout_toRightOf="@+id/Thumbnail"/> 


<TextView android:id="@+id/productlinerow3" 
 android:textColor="#000000" 
 android:textSize="25dip"
 android:text="column2" 
 android:layout_marginTop="10dip"
 android:layout_height="match_parent"  
 android:layout_width="300dip" 
 android:layout_below="@+id/productlinerow"
 android:layout_toRightOf="@+id/Thumbnail"/>

<TextView
      android:id="@+id/qtylabel"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/productlinerow"
      android:layout_toLeftOf="@+id/SOQty"
      android:layout_marginTop="40dip"
      android:layout_marginRight="30dip" 
      android:inputType="number" 
      android:editable="true"
      android:gravity="right" 

      android:text="Order Qty:"
      android:textSize="25dip" />

  <EditText
       android:id="@+id/SOQty"
       android:layout_width="100dip"
       android:layout_height="60dip"
       android:layout_marginTop="25dip"
       android:layout_toLeftOf="@+id/SOCatLine"
       android:layout_marginRight="30dip"
       android:layout_below="@+id/productlinerow"
       android:text="1"
       android:maxLength="3"
       android:inputType="number"
       android:singleLine="true"
       android:textSize="25dip" 
       android:imeOptions="flagNoExtractUi"
       android:selectAllOnFocus="true"/>

 <Button android:text="Add" android:background="@drawable/green_button"  

 android:id="@+id/SOCatLine"
 android:textSize="25dip" 
 android:textColor="#FFFFFF" 
 android:layout_width="130dip" 
 android:layout_marginTop="30dip" 
 android:layout_height="wrap_content" 
 android:layout_below="@+id/productlinerow"
 android:layout_alignParentRight="true"
  />



</RelativeLayout>
  • 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-08T21:56:28+00:00Added an answer on June 8, 2026 at 9:56 pm

    You have to store the text of button in some kind of collection. As you can using HashMap here you can create one more Object of HashMap that will store the text of Button inside getView() using

    bAdd.setText(((HashMap<String,String>) getItem(position)).get("btn_text"));
    

    then you can setTag() the instance to use in onClick()

    bAdd.setTag((HashMap<String,String>) getItem(position));
    

    And then inside onClick() use getTag() to get the position of the Button.

    @Override
            public void onClick(View v) {
            HashMap<String,String> map = (HashMap<String,String>)v.getTag();
            map.put("btn_text", "Change");
            ((Button)v).setText(map.get("btn_text"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that is driving me nuts and hoping someone can help.
Hoping someone can help with this. I have other VM's that dont have problems,
im hoping someone can help me quickly with a question i have. As site
I am hoping someone can help me with a question i have relating to
I am hoping someone can help me out with a quick question I have
I'm hoping someone can help on this one, I have created a custom object
I have a question regarding the OnItemDataBound event and I'm hoping someone can help
everyone. I have an advanced T4 question and I'm hoping someone can help. I've
Hoping someone can help a new iOS developer out - I have a ready
I am hoping someone can help me (once again). I have a very large

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.