0

I'm trying to add to the first group of the new layout. But the disclosure of the groups, the new layout appears in the other groups. I want a new layout was added only in the first group expandblelistview. But my clumsy code adds it in all groups, and these groups do not clickable.

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
                         View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.mylistview, parent, false);
    }
    if(groupPosition == 0)
    {
        LinearLayout fl = (LinearLayout)convertView.findViewById(R.id.mylistview);
        View fl2 = inflater.inflate(R.layout.infoday, fl, true);
        //fl.addView(fl2);
    }
    TextView textChild = (TextView)convertView.findViewById(R.id.textView22);
    Group group = (Group)getGroup(groupPosition);
    textChild.setText(group.string);
    return convertView;
}

My list

<?xml version="1.0" encoding="utf-8"?><FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ExpandableListView
    android:id="@+id/expListView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="true">
</ExpandableListView>

My group in list

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="vertical"
tools:context=".MainActivity"
android:id="@+id/mylistview">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Medium Text"
    android:id="@+id/textView22"
    android:textSize="14sp"
    android:layout_marginTop="20dp"
    android:layout_marginLeft="35dp" />

My new layout, which i want to add

<?xml version="1.0" encoding="utf-8"?><FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frameinfoday"
android:paddingBottom="10dp">

<ImageView
    android:layout_width="150dp"
    android:layout_height="25dp"
    android:id="@+id/imageView2"
    android:background="@drawable/day" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:text="СУББОТА"
    android:id="@+id/textView25"
    android:textColor="#ffffffff"
    android:layout_marginLeft="25dp"
    android:layout_marginTop="4dp"
    android:textIsSelectable="true"
    android:textSize="11sp" />

1 Answers1

0
View headerView = View.inflate(this, R.layout.infoday, null);
listView.addHeaderView(headerView);

This is work for me. I add my layout in header listview!

More information: add to header and footer in listview

Community
  • 1
  • 1