我在ExpandavleListView
中有一些奇怪的行为
和组行(并且它与支票一起使用)
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="@string/hello_world"
android:textColor="#FFFFFF"
android:padding="10dp"
android:textSelectHandleLeft="@string/hello_world"
android:textSize="14sp"
android:textStyle="bold" >
</CheckedTextView>
我需要在行中添加其他数据,所以我尝试了
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center_vertical|center_horizontal"
android:background="@android:color/black"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp" >
<TextView
android:id="@+id/textView1"
style="@style/row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="false"
android:focusable="false"
android:padding="10dp"
android:singleLine="false" />
<TextView
android:id="@+id/textView2"
style="@style/row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:background="@color/expanded_row_points"
android:clickable="false"
android:focusable="false"
android:padding="10dp"
android:singleLine="false"
android:textColor="@color/white" />
</LinearLayout>
但它不起作用。
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = minflater.inflate(R.layout.row_merchant, null);
}
//((CheckedTextView) convertView).setChecked(isExpanded);
return convertView;
}
有没有人知道什么是问题,为什么列表在我使用linearlayout时不会扩展并且在我使用checkedtextview时有效?
子视图代码
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
tempChild = (List<Model>) Childtem.get(groupPosition);
TextView text = null;
if (convertView == null) {
convertView = minflater.inflate(R.layout.row_scheme, null);
}
text = (TextView) convertView.findViewById(R.id.textView1);
text.setText(tempChild.get(childPosition).name);
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(activity, tempChild.get(childPosition).name,
Toast.LENGTH_SHORT).show();
}
});
return convertView;
}