【发布时间】:2020-12-31 12:55:34
【问题描述】:
我创建了一个使用 Navigation Drawer Activity(Android Studio 内置)的 Android 应用程序。现在我将一个 ListView 添加到一个名为 fragment_home.xml 的片段中。这是我的代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/songList"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.home.HomeFragment">
<ListView
android:id="@+id/myListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:listSelector="#2196F3"
/>
</RelativeLayout>
这是我的HomeFragment.java 文件
import androidx.fragment.app.Fragment;
public class HomeFragment extends Fragment {
}
现在我想使用来自 fragment_home 布局的 ListView 到我的MainActivity class。那么我该怎么做。
请帮帮我
【问题讨论】:
标签: android listview android-activity layout fragment