本文整理汇总了Java中android.support.v4.widget.SwipeRefreshLayout类的典型用法代码示例。如果您正苦于以下问题:Java SwipeRefreshLayout类的具体用法?Java SwipeRefreshLayout怎么用?Java SwipeRefreshLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SwipeRefreshLayout类属于android.support.v4.widget包,在下文中一共展示了SwipeRefreshLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
private void initView(ViewGroup root) {
mRecyclerView = (RecyclerView) root.findViewById(R.id.test_recycler);
mSwipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.refresh_layout);
mSwipeRefreshLayout.setEnabled(getArguments().getBoolean(REFRESH_SUPPORT));
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(false);
Toast.makeText(mContext, "刷新完成", Toast.LENGTH_SHORT).show();
}
}, 2000);
}
});
}
示例2: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
this.savedInstanceState = savedInstanceState;
mRootView = inflater.inflate(R.layout.fragment_article, container, false);
mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recycler_view_article);
mEmptyView = (FrameLayout) mRootView.findViewById(R.id.empty_container);
mSwipeRefreshLayout = (SwipeRefreshLayout) mRootView.findViewById(R.id.swipe_refresh_layout);
if (mSwipeRefreshLayout != null) {
mSwipeRefreshLayout.setColorSchemeResources(R.color.accent);
mSwipeRefreshLayout.setOnRefreshListener(this);
}
ArticleFetchTask();
return mRootView;
}
示例3: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
listView = (RecyclerView) view.findViewById(R.id.list);
listView.setHasFixedSize(true);
listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
List<ItemList> lists = new ArrayList<ItemList>();
videoadapter = new VideoAdapter(lists);
listView.setAdapter(videoadapter);
mPresent = new VideoPresenter((VideoData.View) this);
srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
srfLayout.setOnRefreshListener(this);
srfLayout.post(() -> onRefresh());
return view;
}
示例4: initView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
private void initView() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("享受阅读的乐趣");
}
drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refreshLayout);
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
toolbar, R.string.app_name, R.string.app_name);
drawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();
refreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_red_light);
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (isHomepage) {
MainFragment mainFragment = (MainFragment) getFragmentByTag("Fragment" + currentId);
mainFragment.getLatestArticleList();
} else {
ThemeFragment themeFragment = (ThemeFragment) getFragmentByTag("Fragment" + currentId);
themeFragment.refreshData();
}
}
});
}
示例5: initView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
private void initView(Context context) {
mContext = context;
View view = LayoutInflater.from(context).inflate(com.wuxiaolong.pullloadmorerecyclerview.R.layout.pull_loadmore_layout, null);
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_dark, android.R.color.holo_blue_dark, android.R.color.holo_orange_dark);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayoutOnRefresh(this));
mRecyclerView = (RecyclerView) view.findViewById(com.wuxiaolong.pullloadmorerecyclerview.R.id.recycler_view);
mRecyclerView.setVerticalScrollBarEnabled(true);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setOnTouchListener(new onTouchRecyclerView());
mFooterView = view.findViewById(R.id.footerView);
loadMoreLayout = (LinearLayout) view.findViewById(R.id.loadMoreLayout);
loadMoreText = (TextView) view.findViewById(R.id.loadMoreText);
mprogressBar = (ProgressBar)view.findViewById(R.id.loadMoreProgressBar) ;
mFooterView.setVisibility(View.GONE);
this.addView(view);
}
示例6: initWidget
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
/**
* 初始化组件
*/
private void initWidget() {
weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
titleCity = (TextView) findViewById(R.id.title_city);
degreeText = (TextView) findViewById(R.id.degree_text);
weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
aqiText = (TextView) findViewById(R.id.aqi_text);
aqiQualityText = (TextView) findViewById(R.id.aqi_quality_text);
comfortText = (TextView) findViewById(R.id.comfort_text);
carWashText = (TextView) findViewById(R.id.car_wash_text);
dressText = (TextView) findViewById(R.id.dress_text);
bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
navButton = (Button) findViewById(R.id.nav_button);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
}
示例7: initSwipeRefreshLayout
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
private void initSwipeRefreshLayout() {
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
isLoading = true;
saveCurrentTime(TAG);
pageIndex = 1;
isFirstLoading = true;
onBackgrounds();
}
});
mSwipeRefreshLayout.setColorSchemeResources(R.color.color_progress_1, R.color.color_progress_2);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
pageIndex = 1;
isFirstLoading = false;
onBackgrounds();
createRefreshSnackbar(mRecyclerView, TAG);
}
});
}
示例8: doAdapter
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
public void doAdapter() {
viewed = true;
dataSet = new FeedLoader(id, getActivity());
adapter = new FeedAdapter(getActivity(), dataSet, rv, mSwipeRefreshLayout);
adapter.setHasStableIds(true);
rv.setAdapter(adapter);
if(dataSet.feed.getArticles().isEmpty()) {
dataSet.loadMore(getActivity(), adapter);
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});
}
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refresh();
}
});
}
示例9: setFragmentView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
protected View setFragmentView(LayoutInflater inflater, @Nullable ViewGroup container) {
contentView = inflater.inflate(R.layout.test_success_fragment_gf, container, false);
ButterKnife.bind(this, contentView);
tvTitle.setText("测试二");
activity.setSupportActionBar(toolbar);
tvRefresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoadReTryRefreshManager.getInstance().startLoad(TestSuccessFragment.this);
}
});
LoadReTryRefreshManager.getInstance().register(this, contentView, this);
refreshLayout.setColorSchemeResources(R.color.colorPrimary);
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
loadAndRetry();
}
});
return contentView;
}
示例10: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_events, container, false);
vSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeContainer);
vSwipeRefreshLayout.setOnRefreshListener(this);
vSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.primary));
vSwipeRefreshLayout.setEnabled(true);
vRecyclerView = (RecyclerView) view.findViewById(R.id.cardList);
vRecyclerView.setHasFixedSize(false);
final LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setOrientation(LinearLayoutManager.VERTICAL);
vRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// So the user didn't accidentally refresh on pulling up
vSwipeRefreshLayout.setEnabled(llm.findFirstCompletelyVisibleItemPosition() == 0 || (llm.findFirstVisibleItemPosition() == 0 && llm.findFirstCompletelyVisibleItemPosition() == -1));
}
});
vRecyclerView.setLayoutManager(llm);
return view;
}
示例11: initViews
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
protected void initViews(Bundle savedInstanceState) {
setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getIntent().getStringExtra(KEY_EXTRA_NAME));
refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refeshLayout);
refreshLayout.setColorSchemeResources(ThemeUtil.getCurrentColorPrimary(this));
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
loadData();
}
});
recyclerView = (RecyclerView) findViewById(R.id.rv_station_line);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter = new StationDetailAdapter(R.layout.item_bus_line, null);
recyclerView.setAdapter(adapter);
}
示例12: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.chat_fragment_group, container, false);
//listGroup = GroupDB.getInstance(getContext()).getListGroups();
listGroup = new ArrayList<>();
recyclerListGroups = (RecyclerView) layout.findViewById(R.id.recycleListGroup);
mSwipeRefreshLayout = (SwipeRefreshLayout) layout.findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setOnRefreshListener(this);
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
recyclerListGroups.setLayoutManager(layoutManager);
adapter = new ListMovieAdapter(getContext(), listGroup);
recyclerListGroups.setAdapter(adapter);
if(listGroup.size() == 0){
//Ket noi server hien thi group
mSwipeRefreshLayout.setRefreshing(true);
getListGroup();
}
return layout;
}
示例13: onCreateView
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_convocatorias, container, false);
swipeRefreshLayoutConvocatorias = (SwipeRefreshLayout) v.findViewById(R.id.swipelayout_convocatorias);
rvConvocatoria = (RecyclerView) v.findViewById(R.id.rv_convocatoria);
tvEmptyConvocatoria = (TextView) v.findViewById(R.id.tv_empty_convocatoria);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
rvConvocatoria.setLayoutManager(llm);
updateList();
primeraLlamada();
if (noHayDatosEnRealm()) {
tvEmptyConvocatoria.setVisibility(View.VISIBLE);
}
swipeRefreshLayoutConvocatorias.setOnRefreshListener(() -> primeraLlamada());
return v;
}
示例14: initEventAndData
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
@Override
protected void initEventAndData() {
nodeName = getIntent().getStringExtra(Constants.IT_VTEX_NODE_NAME);
setToolBar(toolBar, nodeName);
mAdapter = new NodeListAdapter(mContext, new ArrayList<NodeListBean>());
rvContent.setLayoutManager(new LinearLayoutManager(mContext));
rvContent.setAdapter(mAdapter);
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mPresenter.getContent(nodeName);
}
});
ivProgress.start();
mPresenter.getContent(nodeName);
mPresenter.getTopInfo(nodeName);
}
示例15: doAdapter
import android.support.v4.widget.SwipeRefreshLayout; //导入依赖的package包/类
public void doAdapter() {
dataSet = new SearchLoader(search);
adapter = new FeedAdapter(getActivity(), dataSet, rv, mSwipeRefreshLayout);
adapter.setHasStableIds(true);
rv.setAdapter(adapter);
if (dataSet.getData().isEmpty()) {
new AlertDialogWrapper.Builder(getActivity()).setTitle("No results").setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getActivity().finish();
}
}).show();
}
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
refresh();
}
});
}