[英]How can I save and load to clouds like Dropbox, OneDrive and iCloud on Android/iOS with Gluon and javafx?
[英]How can i create folders list like DropBox in android?
我想在Android的列表视图中显示文件夹,但我必须构建一些不是静态预制的片段,因为我不知道文件夹树的样子。 我想创建类似保管箱的东西。 当文件夹内容更改时,它们如何显示文件夹内容列表。 如何在运行时使用listview生成这些片段?
显然,并非应用程序的所有内容都必须是静态的。 在Android上,实现“ DropBox文件夹内容”类型表示的一种方法是使用ListView。
基本上,您要做的是创建ListView的实例(通过将其添加到布局或以编程方式添加到ViewGroup)并为其设置有效的Adapter。
适配器负责处理“可变”数据。
可以在这里找到一个不错而全面的教程-在Android中使用列表(ListView)-教程
编辑:
要在运行时创建片段,请在收到onItemClick事件后,尝试以下方法:
创建一个Activity并将此View包含在其布局中:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar" android:theme="@style/Style" />;
创建一个方法,类似于以下内容:
instantiateNewFolder(NewFolderDescriptor descriptor){ FragmentManager fragmentManager = getSupportFragmentManager(); // or getFragmentManager() FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out); fragmentTransaction.replace(R.id.fragment_container, NewFolderFragment.instantiateNew(descriptor)); fragmentTransaction.commit(); }
在onCreate()以及需要显示新片段时调用此方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.