I tried to keep edit text in group view of expandable listview.If i keep edit text Expanded and collapse not working for the groupview.
I tried with other views like text view and check boxes group view working fine .
May you know what was the reason for expand and collapse not working with edittext.
Sample wroking groupview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8cae88"
android:orientation="horizontal"
android:padding="8dp" >
<TextView
android:id="@+id/lblListHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
android:paddingTop="5dp"
android:textColor="#f9f93d"
android:textSize="17dp" />
<TextView
android:id="@+id/textOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="SampleTxt"
android:textColor="#f9f93d"
android:textSize="17dp" />
</LinearLayout>
Sample after adding edittext not wroking groupview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8cae88"
android:orientation="horizontal"
android:padding="8dp" >
<TextView
android:id="@+id/lblListHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"
android:paddingTop="5dp"
android:textColor="#f9f93d"
android:textSize="17dp" />
<TextView
android:id="@+id/textOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="SampleTxt"
android:textColor="#f9f93d"
android:textSize="17dp" />
<EditText
android:id="@+id/b_discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingTop="5dp" />
</LinearLayout>
Here is the ExpandableListAdapter getGroupView method code
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);convertView.setBackgroundResource(R.color.blue_list_dashboard);
return convertView;
}
Thanks for advance.
I was facing the same issue. Didn't able to find the solution. Tried all the things. But what i did is :-
<Linearlayout>
<edittext> (Gone)
</Linearlayout>
When user click on edittext just visible the edittext and put focus on edittext. Just a kind of trick.
If any one have the best solution please come up. Because it not a good way. But its working.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.