我正在使用这个库Android-PullToRefresh:https://github.com/chrisbanes/Android-PullToRefresh
我需要在活动开始时实现自动"拉动刷新",即具有与拉动自动触发的片段而不是用户拉动手势相同的视觉和功能效果.你知道我能做到吗?
编辑:我的代码如下
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved)
{
View view = inflater.inflate(R.layout.layout_frg_summarized, group, false);
mPullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.summary_layout);
ActionBarPullToRefresh.from(getActivity())
.allChildrenArePullable()
.listener(this)
.setup(mPullToRefreshLayout);
return view;
}
@Override
public void onActivityCreated (Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
//some code here
mPullToRefreshLayout.isRefreshing();
}
@Override
public void onResume(){
super.onResume();
if (mPullToRefreshLayout.isRefreshing()) {
mPullToRefreshLayout.setRefreshing(true);
}
}
@Override
public void onPause(){
super.onPause();
mPullToRefreshLayout.setRefreshing(false);
if (mPullToRefreshLayout.isRefreshing()) {
mPullToRefreshLayout.setRefreshComplete();
}
}
Run Code Online (Sandbox Code Playgroud) 我创建了一个Custom ProgressDialog,如下所示:首先,我有一个带有9个连续Imges的动画列表
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<item android:drawable="@drawable/icon_progress_dialog_drawable_1" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_2" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_3" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_4" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_5" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_6" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_7" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_8" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_9" android:duration="150" />
Run Code Online (Sandbox Code Playgroud)
然后我有一个自定义的风格
<style name="CustomDialog" parent="@android:style/Theme.Dialog" >
<item name="android:windowFrame">@null</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:gravity">center</item>
<item name="android:minHeight">70dip</item>
<item name="android:maxHeight">80dip</item>
Run Code Online (Sandbox Code Playgroud)
现在在代码中我将其称为如下
dialog = new ProgressDialog(KaguaHome.this);
dialog.setProgressStyle(R.style.CustomDialog);
dialog.setIndeterminate(true);
dialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress_dialog_icon_drawable_animation));
dialog.show();
Run Code Online (Sandbox Code Playgroud)
结果是

然而,我想要只用图像(没有白色背景)来实现进度对话框,它应该居中,我应该修改什么?
我有一个RecyclerView用于显示使用内容提供程序从内容提供程序获取的数据LoaderManager.它工作正常,但我注意到加载大数据时我的下面的实现有一些性能问题,显示数据有一个滞后,因为我使用a ViewPager加载Fragment主机这个方法
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
Favorites = new ArrayList<>();
if (cursor != null) {
while (cursor.moveToNext())
Favorites.add(FavoritesModel.fromCursor(cursor));
}
adapter = new FavoritesAdapter(getActivity(),Favorites);
favoritesRecyclerView.setAdapter(adapter);
}
Run Code Online (Sandbox Code Playgroud)
所以我选择做以下事情:
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
........
adapter = new FavoritesAdapter(getActivity(),Favorites);
favoritesRecyclerView.setAdapter(adapter);
........
Run Code Online (Sandbox Code Playgroud)
然后在onLoadFinished上
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
Favorites = new ArrayList<>();
if (cursor != null) {
while (cursor.moveToNext())
Favorites.add(FavoritesModel.fromCursor(cursor));
}
adapter.notifyDataSetChanged();
}
Run Code Online (Sandbox Code Playgroud)
使用此功能无需显示.什么是问题,因为onLoadFinished总是被调用,我知道它始终在UI线程上调用
我想实现类似于pirate Bay使用的节标题
基本上是这样的Listview:
标题名称列表项目列表项目列表项目列表项目标题名称列表项目列表项目列表项目
这是实现这一目标的最佳方式?我已阅读部分标题和合并适配器,但它们不能满足我的需求......我将如何实现节标题
android ×4