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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:06:26+00:00 2026-06-16T13:06:26+00:00

I have a ListView that have in each row 2 TextView and a CheckBox.

  • 0

I have a ListView that have in each row 2 TextView and a CheckBox.

I have a drawable (a line), that I want once the user check the CheckBox that the drawable will be scale as an animation at the background of the checked CheckBox row, I was able in my getView() method on my Custom Adapter, to animate the drawable as a background but it also scale the 2 TextView and the CheckBox, and I want that only the drawable background will be scale as an animation, how do i do that?

here is my getView() method on the custom adapter:

public View getView(final int position, View convertView, final ViewGroup parent) {
    final ViewHolder holder;

    LayoutInflater inflater = LayoutInflater.from(context);
    convertView = inflater.inflate(R.layout.listview_item_row, parent, false);
    // cache view fields into the holder
    holder = new ViewHolder();
    holder.itemTitle = (TextView) convertView.findViewById(R.id.itemTitle);
    holder.itemQuantity = (TextView) convertView.findViewById(R.id.itemQuantity);
    holder.itemCheck = (CheckBox) convertView.findViewById(R.id.itemCheck);
    convertView.setTag(holder);

    final Cursor cursor = getCursor();
    final View rowView = convertView;
    cursor.moveToPosition(position);
    holder.itemTitle.setText(cursor.getString((cursor.getColumnIndex(MySQLiteHelper.KEY_NAME))));
    holder.itemQuantity.setText(cursor.getString((cursor.getColumnIndex(MySQLiteHelper.KEY_QUANTITY))));
    holder.itemCheck.setChecked(cursor.getInt(cursor.getColumnIndex(MySQLiteHelper.KEY_CHECKED)) == 1);

    holder.itemCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() { 
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    cursor.moveToPosition(position);
                    itemsDataSource.updateItemCheckBox(1, cursor.getLong(cursor.getColumnIndex(MySQLiteHelper.KEY_ID)));
                    itemsDataSource.updateRoute(cursor.getString(cursor.getColumnIndex(MySQLiteHelper.KEY_NAME)), true);
                    Animation drawLine = AnimationUtils.loadAnimation(context, R.anim.item_done);
                    rowView.setBackgroundResource(R.drawable.line);
                    rowView.startAnimation(drawLine);
                    ShowListActivity.PRIORITY++;
                }
                else {
                    cursor.moveToPosition(position);
                    itemsDataSource.updateItemCheckBox(0, cursor.getLong(cursor.getColumnIndex(MySQLiteHelper.KEY_ID)));
                    itemsDataSource.updateRoute(cursor.getString(cursor.getColumnIndex(MySQLiteHelper.KEY_NAME)), false);
                    rowView.setBackgroundResource(0);
                    ShowListActivity.PRIORITY--;
                }

            }
        });
    if (holder.itemCheck.isChecked()) rowView.setBackgroundResource(R.drawable.line);
    else rowView.setBackgroundResource(0);
    return rowView;
}
private static class ViewHolder {
    TextView itemTitle;
    TextView itemQuantity;
    CheckBox itemCheck;     
}
  • 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-16T13:06:27+00:00Added an answer on June 16, 2026 at 1:06 pm

    update

    I managed to solve the problem:

    first I changed the custom row layout file like this:

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frameRowLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:weightSum="10">
    
    <LinearLayout android:id="@+id/rowLayout" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" >
    
            <CheckBox android:id="@+id/itemCheck" 
                android:layout_width="0dp" 
                android:layout_height="wrap_content" 
                android:layout_marginBottom="5dp" 
                android:layout_marginTop="5dp" 
                android:layout_weight="2" android:gravity="center" 
                android:focusable="false" 
                android:focusableInTouchMode="false" 
                android:singleLine="false" />
    
           <TextView android:id="@+id/itemTitle" 
               android:layout_width="0dp" 
               android:layout_height="fill_parent" 
               android:layout_marginBottom="5dp" 
               android:layout_marginTop="5dp" 
               android:layout_weight="6" 
               android:gravity="center" 
               android:text="some text1" 
               android:textColor="#2B89A8" 
               android:textSize="22dp" 
               android:textStyle="bold" />
    
           <TextView android:id="@+id/itemQuantity" 
               android:layout_width="0dp" 
               android:layout_height="fill_parent" 
               android:layout_marginBottom="5dp" 
               android:layout_marginTop="5dp" 
               android:layout_weight="2" 
               android:gravity="center" 
               android:text="some text2" 
               android:textColor="#2B89A8" 
               android:textSize="22dp" 
               android:textStyle="bold" />
    
    </LinearLayout>
    
    <View
        android:id="@+id/backgroundView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    
    </FrameLayout>
    

    the whole idea of Framelayout is that views can overlap each other, there for the View after the LinearLayout is overlapping the LinearLayout.

    then I changed my getView() method in my custom adapter as Following:

    public View getView(final int position, View convertView, final ViewGroup parent) {
        final ViewHolder holder;
    
        LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.listview_item_row, parent, false);
        // cache view fields into the holder
        holder = new ViewHolder();
        holder.itemTitle = (TextView) convertView.findViewById(R.id.itemTitle);
        holder.itemQuantity = (TextView) convertView.findViewById(R.id.itemQuantity);
        holder.itemCheck = (CheckBox) convertView.findViewById(R.id.itemCheck);
        holder.rowView = (View) convertView.findViewById(R.id.backgroundView);
        convertView.setTag(holder);
    
        final Cursor cursor = getCursor();
        cursor.moveToPosition(position);
        holder.itemTitle.setText(cursor.getString((cursor.getColumnIndex(MySQLiteHelper.KEY_NAME))));
        holder.itemQuantity.setText(cursor.getString((cursor.getColumnIndex(MySQLiteHelper.KEY_QUANTITY))));
        holder.itemCheck.setChecked(cursor.getInt(cursor.getColumnIndex(MySQLiteHelper.KEY_CHECKED)) == 1);
    
        holder.itemCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() { 
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) {
                        cursor.moveToPosition(position);
                        itemsDataSource.updateItemCheckBox(1, cursor.getLong(cursor.getColumnIndex(MySQLiteHelper.KEY_ID)));
                        itemsDataSource.updateRoute(cursor.getString(cursor.getColumnIndex(MySQLiteHelper.KEY_NAME)), true);
                        Animation drawLine = AnimationUtils.loadAnimation(context, R.anim.item_done);
                        holder.rowView.setBackgroundResource(R.drawable.line);
                        holder.rowView.startAnimation(drawLine);
                        ShowListActivity.PRIORITY++;
                    }
                    else {
                        cursor.moveToPosition(position);
                        itemsDataSource.updateItemCheckBox(0, cursor.getLong(cursor.getColumnIndex(MySQLiteHelper.KEY_ID)));
                        itemsDataSource.updateRoute(cursor.getString(cursor.getColumnIndex(MySQLiteHelper.KEY_NAME)), false);
                        holder.rowView.setBackgroundResource(0);
                        ShowListActivity.PRIORITY--;
                    }
    
                }
            });
        if (holder.itemCheck.isChecked()) holder.rowView.setBackgroundResource(R.drawable.line);
        else holder.rowView.setBackgroundResource(0);
        return convertView;
    }
    private static class ViewHolder {
        TextView itemTitle;
        TextView itemQuantity;
        CheckBox itemCheck; 
        View rowView;
    }
    

    hope you can understand what I did.

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

Sidebar

Related Questions

I'm trying to have a ListView that will display each row in a given
I have a listview with custom rows and that extends SimpleAdapter. Each row consist
I have a ListView that uses SimpleAdapter, each row has 2 TextViews, and I
I have a listview with one textview and a button in each row. Button
I have a customized ListView that each row of the list is composed by
I have a ListView that is fed by an SQLiteDB. On each row returned,
I have a custom listview row that contains a number of textView components. Instead
I have created a custom listview that is populated using a row.xml file. Each
I have created one listview, in this each row contain check box and the
I have listView , each row of which is looking like that: <?xml version=1.0

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.