繁体   English   中英

具有EditText Expanded的ExpandableListView GroupView无法正常工作

[英]ExpandableListView GroupView with an EditText Expanded not working

我试图将编辑文本保留在可扩展列表视图的组视图中。

我尝试使用其他视图(如文本视图和复选框组视图)正常工作。

也许您知道扩展和折叠不使用edittext的原因是什么。

样本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>

添加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>

这是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;
        }

感谢前进。

我面临着同样的问题。 找不到解决方案。 试了所有的东西。 但是我所做的是:-

 <Linearlayout>  
    <edittext> (Gone)
</Linearlayout>

当用户单击edittext时,仅会看到edittext并将焦点放在edittext上。 只是一种把戏。

如果有任何最佳解决方案,请提出。 因为这不是一个好方法。 但它的工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM