當前位置: 首頁>>代碼示例>>Java>>正文


Java SwipeRefreshLayout類代碼示例

本文整理匯總了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);
        }
    });
}
 
開發者ID:zuoni1018,項目名稱:CoordinatorLayoutExample-master,代碼行數:20,代碼來源:TestFragment.java

示例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;
}
 
開發者ID:prshntpnwr,項目名稱:Monolith,代碼行數:20,代碼來源:ArticleFragment.java

示例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;
}
 
開發者ID:popo1379,項目名稱:popomusic,代碼行數:19,代碼來源:JuqingFragment.java

示例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();
            }
        }
    });
}
 
開發者ID:RONG242,項目名稱:zhihudaily,代碼行數:27,代碼來源:MainActivity.java

示例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);

}
 
開發者ID:dufangyu1990,項目名稱:JKApp,代碼行數:27,代碼來源:PullLoadMoreRecyclerView.java

示例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);
}
 
開發者ID:zhegeshijiehuiyouai,項目名稱:Weather365,代碼行數:20,代碼來源:WeatherActivity.java

示例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);
        }
    });
}
 
開發者ID:jpaijh,項目名稱:TYT,代碼行數:25,代碼來源:T_MyFund_AccountFinancingFragment.java

示例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();
        }
    });
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:24,代碼來源:FeedFragment.java

示例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;
}
 
開發者ID:NoEndToLF,項目名稱:Gif-Load-ReTry-Refresh,代碼行數:23,代碼來源:TestSuccessFragment.java

示例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;
}
 
開發者ID:gregoreesmaa,項目名稱:minu-poska-android,代碼行數:24,代碼來源:EventsFragment.java

示例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);
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:18,代碼來源:StationDetailActivity.java

示例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;
}
 
開發者ID:ansarisufiyan777,項目名稱:Show_Chat,代碼行數:24,代碼來源:MovieFragment.java

示例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;
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:22,代碼來源:ConvocatoriaFragment.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:NodeListActivity.java

示例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();
        }
    });
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:22,代碼來源:SearchFragment.java


注:本文中的android.support.v4.widget.SwipeRefreshLayout類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。