【发布时间】:2018-09-28 04:24:46
【问题描述】:
我想在单个屏幕中设置 3 个 expandablelistview 我想添加多个 expandablelistview
XmlLayout
//this is my scorllview
<ScrollView 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"
android:fillViewport="true"
tools:context=".fragments.FragmentTestWellnessScoreBoard">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/llHealth"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvHealthTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold"
android:layout_margin="@dimen/margin_10"
android:text="Health"/>
<ExpandableListView
android:id="@+id/elHealth"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="@+id/llChallenge"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvChallengeTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold"
android:layout_margin="@dimen/margin_10"
android:text="Challenge"/>
<ExpandableListView
android:id="@+id/elChallenge"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/llRisk"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvRiskTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textStyle="bold"
android:layout_margin="@dimen/margin_10"
android:text="Risk"/>
<ExpandableListView
android:id="@+id/elRisk"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
我想在用户点击时一一设置适配器我不知道如何设置多个expandableList? Java 文件
private TestWellnessScoreBoardExpandableListAdapter mHealthaAdapter;
private TestWellnessScoreBoardExpandableListAdapter mChallengeAdapter;
private TestWellnessScoreBoardExpandableListAdapter mRiskAdapter;
private ExpandableListView elHealth;
private ExpandableListView elChallenge;
private ExpandableListView elRisk;
// this is my click listener to set adapter
private View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tvHealthTitle:
mHealthaAdapter = new TestWellnessScoreBoardExpandableListAdapter(getActivity(), mWellnessResult.getWellnessArrayList());
elHealth.setAdapter(mHealthaAdapter);
break;
case R.id.tvChallengeTitle:
mChallengeAdapter = new TestWellnessScoreBoardExpandableListAdapter(getActivity(), mWellnessResult.getWellnessArrayList());
elChallenge.setAdapter(mChallengeAdapter);
break;
case R.id.tvRiskTitle:
mRiskAdapter = new TestWellnessScoreBoardExpandableListAdapter(getActivity(), mWellnessResult.getWellnessArrayList());
elRisk.setAdapter(mRiskAdapter);
break;
}
}
};
【问题讨论】:
-
尝试使用
NestedScrollView -
@VishvaDave NestedScrollView 不工作我已经尝试过
-
@VishvaDave 感谢链接
-
@VishvaDave 工作正常,非常感谢您
标签: android android-layout expandablelistview expandablelistadapter