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


Java PullToRefreshListView.setOnPullEventListener方法代碼示例

本文整理匯總了Java中com.handmark.pulltorefresh.library.PullToRefreshListView.setOnPullEventListener方法的典型用法代碼示例。如果您正苦於以下問題:Java PullToRefreshListView.setOnPullEventListener方法的具體用法?Java PullToRefreshListView.setOnPullEventListener怎麽用?Java PullToRefreshListView.setOnPullEventListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.handmark.pulltorefresh.library.PullToRefreshListView的用法示例。


在下文中一共展示了PullToRefreshListView.setOnPullEventListener方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import com.handmark.pulltorefresh.library.PullToRefreshListView; //導入方法依賴的package包/類
/** 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(PullToRefreshListActivity.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);

	/**
	 * Add Sound Event Listener
	 */
	SoundPullEventListener<ListView> soundListener = new SoundPullEventListener<ListView>(this);
	soundListener.addSoundEvent(State.PULL_TO_REFRESH, R.raw.pull_event);
	soundListener.addSoundEvent(State.RESET, R.raw.reset_sound);
	soundListener.addSoundEvent(State.REFRESHING, R.raw.refreshing_sound);
	mPullRefreshListView.setOnPullEventListener(soundListener);

	// You can also just use setListAdapter(mAdapter) or
	// mPullRefreshListView.setAdapter(mAdapter)
	actualListView.setAdapter(mAdapter);
}
 
開發者ID:chongbo2013,項目名稱:OverPulltorefresh,代碼行數:56,代碼來源:PullToRefreshListActivity.java


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