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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:41:42+00:00 2026-06-15T12:41:42+00:00

I have an Activity containing a ListView based on SimpleCursorAdapter and a button. When

  • 0

I have an Activity containing a ListView based on SimpleCursorAdapter and a button.
When I click the button, I want the row height to get bigger.
I decided to use TextView height for this on button OnClick:

TextView tvRow = (TextView) findViewById(R.id.tvRow);
tvRow.setHeight(20);

but it changes only the first row of the list.

I can change the height in the Adapter‘s getView method:

TextView tvRow = (TextView) view.findViewById(R.id.tvRow);
tvRow.setHeight(20);

but that’s not the functionality I need; I need this on button OnClick.

How can I change ListView Row height by tapping a button?
Maybe even a trick 🙂
Thank you for your time.

UPDATE:

When I put this code in SimpleCursorAdapter everything works fine, but in method getView in BaseAdapter:

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
   View view = convertView;
if (view == null) {
  view = lInflater.inflate(R.layout.itemF, parent, false);
}
...   
 final LayoutParams params = view.getLayoutParams();
            if (params == null) { 
                view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, mRowHeight)); 
        }else { 
        params.height = mRowHeight; }
return view;

the list at display just ignores this and its row width stays the same. What is wrong?

UPDATE:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<CheckBox
    android:id="@+id/cbBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<LinearLayout
    android:id="@+id/llRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingTop="5dp" >

    <TextView
        android:id="@+id/tvName"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Наименование фирмы"
        android:textAllCaps="true"
        android:textSize="14dp" />

    <TextView
        android:id="@+id/tvAddr"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Адрес фирмы"
        android:textSize="10dp" />
</LinearLayout>

  • 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-15T12:41:44+00:00Added an answer on June 15, 2026 at 12:41 pm

    I think you must chage getView() method of your SimpleCursorAdapter, like this:

    final SimpleCursorAdapter adapter = new SimpleCursorAdapter (context, cursor) {
        @Override
        public View getView (int position, View convertView, ViewGroup parent) {
            final View view = super.getView(position, convertView, parent);
            final TextView text = (TextView) view.findViewById(R.id.tvRow);
            final LayoutParams params = text.getLayoutParams();
    
            if (params != null) {
                    params.height = mRowHeight;
            }
    
            return view;
        }
    }
    

    When you click on your button, you must change mRowHeight and notify ListView about changes like adapter.notifyDataSetChanged(). For the first value of mRowHeight you can set this:

    mRowHeight = LayoutParams.WRAP_CONTENT
    

    UPD:

    If method hasStableIds() of your BaseAdapter return false (it return false as default) you must apply little changes in your getView() (you must set LayoutParams to your View manually):

    LayoutParams params = view.getLayoutParams();
    if (params == null) { 
        params = new LayoutParams(LayoutParams.MATCH_PARENT, mRowHeight); 
    } else {
        params.height = mRowHeight;
    }
    
    view.setLayoutParams(params);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list with rows containing two buttons. Button A in Row X
I have an activity group containing 3 activities. When a button is pressed, I
I have a main activity with a ListView containing a list of names. On
In my example activity, I have - a ListView containing - multiple HorizontalScrollView containing
I have a listview that consist of 23 rows. When I click any row,
In my Android App I have a listview containing 30 rows, and each row
I have an Activity containing an ImageView and I'd like to allow the User
I have Activity with ListView inside it and in the onCreate method of the
in my app i have activity with XML layout, i want to build an
I have a Custom ListView in my application, containing an ImageView and 3-5 TextViews.

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.