今天看Android-PullToRefresh的源代碼,先從它的例子看到LauncherActivity繼承了ListActivity,之前只接觸過Activity,瞬間以爲本身眇小啦,android
在onCreate中將item的內容加入,使用setListAdapter並設置List的格式
this
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, options));對象
第一個參數是對象,第二個參數是list的樣式,第三個是List的內容。繼承
點擊是List返回的方法it
protected void onListItemClick(ListView l, View v, int position, long id) {
Intent intent;
switch (position) {
default:
case 0:
intent = new Intent(this, PullToRefreshListActivity.class);
break;
case 1:
intent = new Intent(this, PullToRefreshExpandableListActivity.class);
break;
case 2:
intent = new Intent(this, PullToRefreshGridActivity.class);
break;
case 3:
intent = new Intent(this, PullToRefreshWebViewActivity.class);
break;
case 4:
intent = new Intent(this, PullToRefreshScrollViewActivity.class);
break;
case 5:
intent = new Intent(this, PullToRefreshHorizontalScrollViewActivity.class);
break;
case 6:
intent = new Intent(this, PullToRefreshViewPagerActivity.class);
break;
case 7:
intent = new Intent(this, PullToRefreshListFragmentActivity.class);
break;
case 8:
intent = new Intent(this, PullToRefreshWebView2Activity.class);
break;
case 9:
intent = new Intent(this, PullToRefreshListInViewPagerActivity.class);
break;io
}
startActivity(intent);
}class
這有掌握一個知識點。。。。加油
List