Search in sources :

Example 1 with PullToRefreshListView

use of com.handmark.pulltorefresh.library.PullToRefreshListView in project MVCHelper by LuckyJayce.

the class PullrefshActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pullrefsh);
    PullToRefreshListView refreshListView = (PullToRefreshListView) findViewById(R.id.pullToRefreshListView);
    mvcHelper = new MVCPullrefshHelper<List<Book>>(refreshListView);
    // 设置数据源
    mvcHelper.setDataSource(new BooksDataSource());
    // 设置适配器
    mvcHelper.setAdapter(new BooksAdapter(this));
    // 加载数据
    mvcHelper.refresh();
}
Also used : BooksAdapter(com.shizhefei.test.view.adapters.BooksAdapter) PullToRefreshListView(com.handmark.pulltorefresh.library.PullToRefreshListView) List(java.util.List) BooksDataSource(com.shizhefei.test.models.datasource.BooksDataSource)

Example 2 with PullToRefreshListView

use of com.handmark.pulltorefresh.library.PullToRefreshListView in project Android-PullToRefresh by chrisbanes.

the class PullToRefreshListActivity method onCreate.

/** 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);
}
Also used : PullToRefreshListView(com.handmark.pulltorefresh.library.PullToRefreshListView) ListView(android.widget.ListView) SoundPullEventListener(com.handmark.pulltorefresh.library.extras.SoundPullEventListener) OnLastItemVisibleListener(com.handmark.pulltorefresh.library.PullToRefreshBase.OnLastItemVisibleListener)

Example 3 with PullToRefreshListView

use of com.handmark.pulltorefresh.library.PullToRefreshListView in project Android-PullToRefresh by chrisbanes.

the class PullToRefreshListFragmentActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ptr_list_fragment);
    mPullRefreshListFragment = (PullToRefreshListFragment) getSupportFragmentManager().findFragmentById(R.id.frag_ptr_list);
    // Get PullToRefreshListView from Fragment
    mPullRefreshListView = mPullRefreshListFragment.getPullToRefreshListView();
    // Set a listener to be invoked when the list should be refreshed.
    mPullRefreshListView.setOnRefreshListener(this);
    // You can also just use mPullRefreshListFragment.getListView()
    ListView actualListView = mPullRefreshListView.getRefreshableView();
    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);
    mPullRefreshListFragment.setListShown(true);
}
Also used : PullToRefreshListView(com.handmark.pulltorefresh.library.PullToRefreshListView) ListView(android.widget.ListView)

Aggregations

PullToRefreshListView (com.handmark.pulltorefresh.library.PullToRefreshListView)3 ListView (android.widget.ListView)2 OnLastItemVisibleListener (com.handmark.pulltorefresh.library.PullToRefreshBase.OnLastItemVisibleListener)1 SoundPullEventListener (com.handmark.pulltorefresh.library.extras.SoundPullEventListener)1 BooksDataSource (com.shizhefei.test.models.datasource.BooksDataSource)1 BooksAdapter (com.shizhefei.test.view.adapters.BooksAdapter)1 List (java.util.List)1