[英]ExpandableListView GroupView with an EditText Expanded not working
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. 也许您知道扩展和折叠不使用edittext的原因是什么。
Sample wroking groupview.xml 样本grouping.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 添加edittext后的示例未修改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 这是ExpandableListAdapter getGroupView方法代码
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. 当用户单击edittext时,仅会看到edittext并将焦点放在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.
但它的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.