com.handmark.pulltorefresh.library.PullToRefreshBase.OnLastItemVisibleListener Java Examples
The following examples show how to use
com.handmark.pulltorefresh.library.PullToRefreshBase.OnLastItemVisibleListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ptr_list); mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list); // Set a listener to be invoked when the list should be refreshed. mPullRefreshListView .setOnRefreshListener(new OnRefreshListener<ListView>() { @Override public void onRefresh( PullToRefreshBase<ListView> refreshView) { String label = DateUtils.formatDateTime( getApplicationContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); // Update the LastUpdatedLabel refreshView.getLoadingLayoutProxy() .setLastUpdatedLabel(label); // Do work to refresh the list here. new GetDataTask().execute(); } }); // Add an end-of-list listener mPullRefreshListView .setOnLastItemVisibleListener(new OnLastItemVisibleListener() { @Override public void onLastItemVisible() { Toast.makeText(MainActivity.this, "End of List!", Toast.LENGTH_SHORT).show(); } }); ListView actualListView = mPullRefreshListView.getRefreshableView(); // Need to use the Actual ListView when registering for Context Menu registerForContextMenu(actualListView); mListItems = new LinkedList<String>(); mListItems.addAll(Arrays.asList(mStrings)); mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mListItems); // You can also just use setListAdapter(mAdapter) or // mPullRefreshListView.setAdapter(mAdapter) actualListView.setAdapter(mAdapter); }
Example #2
Source File: PullToRefreshCustomActivity.java From effective_android_sample with Apache License 2.0 | 4 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ptr_list); mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list); // Set a listener to be invoked when the list should be refreshed. mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() { // ひっぱりきって指をはなしたとき? @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); // Update the LastUpdatedLabel refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label); // Do work to refresh the list here. new GetDataTask().execute(); } }); /** * customize */ mPullRefreshListView.setMode(Mode.BOTH); // LoadingLayoutに関してカスタマイズ(主に文言) ILoadingLayout iLoadingLayout = mPullRefreshListView.getLoadingLayoutProxy(true, true); iLoadingLayout.setLastUpdatedLabel(""); iLoadingLayout.setReleaseLabel("離してください、更新します"); iLoadingLayout.setPullLabel("さらに下に引いて下さい"); iLoadingLayout.setRefreshingLabel("更新中です"); // Add an end-of-list listener mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { @Override public void onLastItemVisible() { Toast.makeText(PullToRefreshCustomActivity.this, "End of List!", Toast.LENGTH_SHORT) .show(); } }); /** * リスト表示 */ mIemsList = new LinkedList<String>(); mIemsList.addAll(Arrays.asList(INITIAL_LIST)); mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mIemsList); ListView actualListView = mPullRefreshListView.getRefreshableView(); actualListView.setAdapter(mAdapter); }