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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:11:51+00:00 2026-05-20T05:11:51+00:00

I want to add a custom view to a group view with a BaseExpandableListAdapter

  • 0

I want to add a custom view to a group view with a BaseExpandableListAdapter

This is The code:

The custom view and layout.xml

public class InfoView extends View{
    private EditText nameEditText;
    private EditText descriptionEditText;
    private Spinner goalTypeSpinner;
    private Spinner categorySpinner;



    Button addGoalCategoryButton;
    public InfoView(Context context) {
        super(context);
        inflate(context, R.layout.info_panel, parent);
        nameEditText = (EditText) findViewById(R.id.nameEditText);

        descriptionEditText = (EditText) findViewById(R.id.descriptionEditText);

        goalTypeSpinner = (Spinner) 
                findViewById(R.id.goalTypeSpinner);

        categorySpinner = (Spinner) 
                findViewById(R.id.categorySpinner);
    }
}

infopanel.xml

<LinearLayout 
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" >
    <Spinner android:id="@+id/goalTypeSpinner" android:prompt="@string/goalType"
            android:entries="@array/goalTypeList" style="@style/commonText.commonSpinner" >
    </Spinner>
    <TableRow style="@style/commonText.commonTableRow">

            <Spinner android:id="@+id/categorySpinner" style="@style/commonText.commonSpinner.right"
                android:prompt="@string/goalType">
            </Spinner>
            <Button android:id="@+id/newCategoryButton" style="@style/commonText.commonButton"
                android:text="add category" />
    </TableRow> 
    <EditText android:id="@+id/nameEditText" android:hint="@string/nameEditTextHint"
        style="@style/commonText.commonEditText" >
    </EditText>
    <EditText android:id="@+id/descriptionEditText" android:hint="@string/descriptionEditTextHint"
        style="@style/commonText.commonTextArea">
    </EditText>

</LinearLayout>

In the BaseExpandableListAdapter :

..............
InfoView infoView;
public View getChildView(int groupPosition, int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {

        if (group.equals(INFO) && child.equals(INFO)) {
            Log.i(TAG, "group INFO(" + group + ")");

            if (infoView == null) {

                // i don't want to recreate everytime 
                // the view so i check if is null         

                infoView = new InfoView(context);
            }

            return infoView;
        }
........

The code works (ie doesn’t throw any exception) but the view isn’t displayed.

Do you know Why ?

thanks and regards

  • 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-05-20T05:11:51+00:00Added an answer on May 20, 2026 at 5:11 am

    The proper way to implement getChildView is to use the provided convertView. Don’t keep reference of any Views created in getChildView.

    public View getChildView(int groupPosition, int childPosition,
                            boolean isLastChild, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = new InfoView(context);
        }
        return convertView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I want to add a custom view (custom_view.xml and
I have created a Dynamic View Panel custom control and want to add a
I want add my custom sidebar next right column all page. Please check this
I want to add a custom UIImageView to UISearchDisplayController's table view background and set
For example I have my custom ExpandableListAdapter extends BaseExpandableListAdapter, it has two groups. public
I want to add a background image for some labels in my custom view.
Hi i have a linear layout and i want to show my custom view
I have a view that I want to add some custom drawing to. I
I want to add custom jump list entries to my application in Windows 7.
I want to add custom attribute settings to a generated anchor link of Wordpress.

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.