Android Fragment实现列表和内容联动

jdqunfa_com 16 0 PDF 2021-01-10 11:01:59

在平板上经常能看到这种的情况:左边是一个列表,右边是列表项对应的内容,当点击某一个列表时,右边内容区也会随之改变。下面使用Fragment简单的demo: 思路:在MainActivity定义一个回调接口,并在列表点击回调该接口,然后在内容区的Fragment设置回调,同时改变Fragment的显示内容。具体代码如下: 主布局: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=horizontal android:layout_width=m

用户评论
请输入评论内容
评分:
暂无评论