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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:44:32+00:00 2026-06-11T21:44:32+00:00

I have an ExpandableListView . The xml for the Child rows looks like this:

  • 0

I have an ExpandableListView. The xml for the Child rows looks like this:

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/number_input_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:gravity="right"
            android:inputType="numberDecimal" >

            <requestFocus />
        </EditText>

        <Spinner
            android:id="@+id/spinner_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/temp_txt" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/number_input_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:gravity="right"
            android:inputType="numberDecimal" />

        <Spinner
            android:id="@+id/spinner_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
    </LinearLayout>
</LinearLayout>

Basically, my getChildView looks like this:

public View getChildView(int i, int i1, boolean b, View view, ViewGroup viewGroup) {

    if (view == null) {
        view = inflater.inflate(R.layout.list_item_child, viewGroup, false);
    }      
    Spinner spinner = (Spinner) view.findViewById(R.id.spinner_1);
    spinner.setAdapter(mUnitsCA);
    spinner.setSelection(14);  // 14 is a test
    spinner.setOnItemSelectedListener(mSpinnerListener);

    return view;
}

This should ensure that item number 14 in spinner_1 is selected every time. Some of the time this works, but often it selects the first item in the spinner instead. I can’t work out where this is happening. Any ideas?

  • 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-11T21:44:33+00:00Added an answer on June 11, 2026 at 9:44 pm

    One recommendation I found was to change setSelection() to the following:

    spinner.setSelection(14, true);
    

    Edit: (Building upon my answer for future seekers)

    The documentation seems to be very vague on this, simply stating the following:

    setSelection(int position, boolean animate);
    //Jump directly to a specific item in the adapter data.
    

    In my research it seems that many have had the same issues and from what I can tell declaring the animation boolean seems to be necessary more often then not, whether it be true or false. Maybe only custom animations or declared animation’s require a boolean value of true in order to animate but not having an animation will accept either true or false…

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

Sidebar

Related Questions

<?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent> <LinearLayout android:id=@+id/li android:layout_alignParentTop=true android:layout_width=match_parent android:layout_height=50dip android:orientation=horizontal android:background=@drawable/title_bg>
If i have a expandablelistview with custom layout (group.xml and child.xml), the are any
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have the following problem: I would like to change value of ExpandableListView's cell
I have an ExpandableListView backed by a BaseExpandableListAdapter. The child list items are all
I have a Dynamic ExpandableListView. That is to say child are only load when
I have added an ExpandableListView to a LinearLayout in an Activity. On the emulator,
I have problem in this layout that : it doesn't show any child after
I have an ExpandableListView (ELV) with the groups having LinearLayout. I have set the

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.