Android:加载facebook和twitter等数据

car*_*ra3 3 android

我只是想知道如何加载Twitter和Facebook应用程序的数据..

就像当你到达页面末尾时,你仍然在与UI进行交互,它显示了正在加载的更多数据.这是如何以编程方式完成的.

更清楚的是,当您到达某个点时向下滚动新闻源时,它会显示一个圆圈,表示正在加载更多数据,然后当有更多新的Feed可用时,您也可以滚动浏览它...我希望我足够清楚..我只是想知道这种情况是如何实施的..有什么例子吗?

And*_*lva 6

这里有一些链接可以帮助您完成它.

http://github.com/commonsguy/cwac-endless

Android无尽列表

http://www.androidguys.com/2009/10/21/tutorial-autogrowing-listview/

来自链接二的示例逻辑,

public class Test extends ListActivity implements OnScrollListener {

Aleph0 adapter = new Aleph0();

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setListAdapter(adapter); 
    getListView().setOnScrollListener(this);
}

public void onScroll(AbsListView view,
    int firstVisible, int visibleCount, int totalCount) {

    boolean loadMore = /* maybe add a padding */
        firstVisible + visibleCount >= totalCount;

    if(loadMore) {
        adapter.count += visibleCount; // or any other amount
        adapter.notifyDataSetChanged();
    }
}

public void onScrollStateChanged(AbsListView v, int s) { }    

class Aleph0 extends BaseAdapter {
    int count = 40; /* starting amount */

    public int getCount() { return count; }
    public Object getItem(int pos) { return pos; }
    public long getItemId(int pos) { return pos; }

    public View getView(int pos, View v, ViewGroup p) {
            TextView view = new TextView(Test.this);
            view.setText("entry " + pos);
            return view;
    }
}
}
Run Code Online (Sandbox Code Playgroud)