gpt4 book ai didi

android - SwipeRefreshLayout setRefreshing() 最初不显示指示器

转载 作者:IT老高 更新时间:2023-10-28 12:57:30 24 4
gpt4 key购买 nike

我有一个非常简单的布局,但是当我在 fragment 的 onActivityCreated() 中调用 setRefreshing(true) 时,它最初不会显示。

它只在我拉动刷新时显示。任何想法为什么它最初没有出现?

fragment xml:

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

</RelativeLayout>


</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

fragment 代码:

public static class LinkDetailsFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {

@InjectView(R.id.swipe_container)
SwipeRefreshLayout mSwipeContainer;

public static LinkDetailsFragment newInstance(String subreddit, String linkId) {
Bundle args = new Bundle();
args.putString(EXTRA_SUBREDDIT, subreddit);
args.putString(EXTRA_LINK_ID, linkId);

LinkDetailsFragment fragment = new LinkDetailsFragment();
fragment.setArguments(args);

return fragment;
}

public LinkDetailsFragment() {
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

mSwipeContainer.setOnRefreshListener(this);
mSwipeContainer.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
mSwipeContainer.setRefreshing(true);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_link_details, container, false);
ButterKnife.inject(this, rootView);
return rootView;
}

@Override
public void onRefresh() {
// refresh
}
}

最佳答案

面临同样的问题。我的解决方案 -

mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});

关于android - SwipeRefreshLayout setRefreshing() 最初不显示指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26858692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com