我想在单击特定组时更改组上的图像。我创建了自己的自定义基本适配器来扩充可扩展列表。在里面getGroupView我有以下代码来更改扩展组上的图像。但是在扩展时,图像在未扩展的组中发生变化。
有什么解决办法吗?
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
ImageView categoryImage = (ImageView)
convertView.findViewById(R.id.menu_category_image);
category.setText(subItems.get(groupPosition).getCategoryName());
if(isExpanded) {
categoryImage.setImageResource(R.drawable.dn_arrow);
} else
categoryImage.setImageResource(R.drawable.right_arrow);
return convertView;
}
Run Code Online (Sandbox Code Playgroud) 我正在创建ExpandableList视图Fragment,组项目显示在列表中,但是当我触摸组项目时,它没有扩展。
下面是我的片段
public class InstituteFragment extends Fragment {
ExpandableListView expandableListView;
ArrayList<String> subjectName;
HashMap<String,ArrayList<String>> topicName;
public InstituteFragment() {
}
public static InstituteFragment newInstance(){
InstituteFragment fragment = new InstituteFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
subjectName = new ArrayList<>();
topicName = new HashMap<>();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_institute, container, false);
prepData();
expandableListView = (ExpandableListView)view.findViewById(R.id.expd_list_view);
SubjectAdapter adapter = new SubjectAdapter(getActivity(),subjectName,topicName);
expandableListView.setAdapter(adapter);
return view;
}
private …Run Code Online (Sandbox Code Playgroud) 以下是我的 getChildView 方法
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final String childText = (String) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.lblListItem);
txtListChild.setText(childText);
return convertView;
}
Run Code Online (Sandbox Code Playgroud)
以下是我的 getGroupView 方法
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
String headerTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) …Run Code Online (Sandbox Code Playgroud) 在 PrimeNG 中 - 有没有办法一次只允许扩展一行?
<p-dataTable [value]="cars" expandableRows="true">
<p-column expander="true" styleClass="col-icon"></p-column>
<p-column field="vin" header="Vin"></p-column>
<ng-template let-car pTemplate="rowexpansion">
...
</p-dataTable>
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个可扩展的ListView内ScrollView。当我想在可扩展 ListView 中滚动时,我必须选择它并在滚动时按住它,否则整个页面都会滚动。这是我的代码
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kitkat.crossroads.JobBidsFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewJobInformation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/bebasneueregular"
android:text="Job Information"
android:textAlignment="center"
android:textSize="30dp"
tools:layout_editor_absoluteX="163dp"
tools:layout_editor_absoluteY="16dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:orientation="horizontal">
<TextView
android:id="@+id/viewName"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/textViewJobName1"
android:layout_alignTop="@id/textViewJobName1"
android:background="#FFFFFFFF"
android:gravity="center_vertical"
android:paddingVertical="10dp"
android:text=" Job:"
android:textAlignment="viewStart"
android:textColor="#FF000000"
android:visibility="visible" />
<TextView
android:id="@+id/textViewJobName1"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:background="#FFFFFFFF"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingVertical="10dp"
android:text="text"
android:textColor="#FF000000"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:orientation="horizontal">
<TextView
android:id="@+id/viewDesc" …Run Code Online (Sandbox Code Playgroud)