嗨,我创建了一个包含滑块抽屉的 android 应用程序。我想在应用程序运行时将动态内容添加到滑块抽屉(从服务器加载图像、文本等)。这可能吗?请帮助我,谢谢:)
问问题
1277 次
2 回答
1
我在github上写了一个演示。在演示中,NavigationDrawerFragment文件就像您的滑块抽屉,抽屉中的主要列表来自此代码 spinnet:
mDrawerListView.setAdapter(new ArrayAdapter<String>(
getActionBar().getThemedContext(),
android.R.layout.simple_list_item_1,
android.R.id.text1,
new String[]{
getString(R.string.title_section1),
getString(R.string.title_section2),
getString(R.string.title_section3),
}));
因此,您可以将其替换为数据加载功能并在文件中加载动态内容。:
public void loadDynamicData(){
//1. show a progress bar when the data is not ready.
//2. use AsyncTask to load data in background.
//3. when data is ready,replace the progress bar with data.
}
如果你还想添加一个 actionbar-pulltorefresh 库,你可以把这个添加到抽屉里。非常简单。如果你想加载图像标志(例如用户的头像),你可以使用picasso。
于 2014-04-05T05:15:31.047 回答
0
如果您在滑块抽屉中使用 ListView,则需要通过 asynctask 加载数据并制作自定义 Listview。
那么,你需要做什么步骤。
- 通过 Asynctask 读取数据。
- 通过此读取数据创建自定义适配器。
- 在 listvoew 中设置此适配器。
还要检查这个链接
于 2014-04-05T04:54:08.750 回答