这是一个我个人认为稍微进阶的列表,因为它多了包覆一层的效果,不过这也是个常出现的元件,虽然稍微复杂了一点,不过整体还是很好理解的,不过它的篇幅有点长我将分成两篇来介绍,今天先来介绍它介面的配置还有资料的设定。
<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="match_parent"
tools:context=".MainActivity">
<ExpandableListView
android:id="@+id/ep1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:childDivider="#2196F3"/>
</LinearLayout>
接着可以再res/layout的资料夹中分别新增两个新的layout,一个负责组的部分,另一个负责子类别的部分。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title_name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center_vertical"
android:paddingLeft="30dp"
android:text="TextView"
android:textStyle="bold"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/content_name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center_vertical|center"
android:text="TextView"
android:textSize="20sp" />
</LinearLayout>
在同MainActivity.java的资料夹中新增两个java档来负责设定组和子类别的资料,简单设计如下。
public class Group {
private String name;
public Group() {
}
public Group (String name){
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class Content {
private String name;
public Content() {
}
public Content (String name){
this.name=name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
<<: Day 30 JavaScript < 简易数据类型介绍 & End>
>>: D30 - 用 Swift 和公开资讯,打造投资理财的 Apps { 台股申购功能扩充,算出价差 }
在技术分析,或是筹码分析的流派中,其中有流派是会用成交量和 K 线一起看,然後进行股票进出的判断。 ...
回圈指的是「重复做某件事,次数随着数值『递增」或『递减』,当数值满足所设的条件,则退出回圈」。 所...
曼陀号领航计画:Girls In Tech 主办的职涯成长计画。此计画所有人员皆以志工形式参与,为期...
Link 在了解了 Next.js 的三种路由方式後,接下来就让我们来聊聊怎麽在 component...
出於书本 Chapter 14. Web sites and Application 使用隐匿性安全...