|  | 
|
| 25 | 26 | 27 | 28 | 29 | 30 | 1 | 
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 31 | 1 | 2 | 3 | 4 | 5 | 
			
	人生就是在破烂的桌面上打台球,
在我以为球肯定会进的时候,
结果球没有进,
在我以为球肯定不会进的时候,
结果,
它还是没进。
 
			
常用链接
留言簿(11)
		随笔分类
		
				
			
	
		随笔档案
		
				
			
	
		文章分类
		
				
			
	
		文章档案
		
				
			
	
		相册
		
				
			
	
		收藏夹
		
				
			
	
		blog 收集
		
				
			
	
		eclipse
		
				
			
	
搜索
最新评论
	
阅读排行榜
评论排行榜
 
	
 
	
					
	
	
			
			android SDK中提供了TabHost使用起来很方便, 但是当tab比较多的时候,就会挤在一起,而不能横向的滚动比较麻烦.
      于是我尝试的制作了一个简单的使用Gallery来代替TabHost的例子, 确实够简单的,自娱自乐.....仅供参考
 
      
 
      使用BroadcastReceiver来切换不同的Tab
 
    public class ChangeTabBroadcastReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            int index = intent.getExtras().getInt(CURRENT_TAB_INDEX);
            Log.i(TAG, "onReceive index = " + index);
            // setCurrentTab(index);
            topBar.setSelection(index);
            startGroupActivity(titleList.get(index).toString(),
                    (Intent) intentList.get(index));
        }
    }
 
     没有详细研究SDK中的TabHost实现机制, 使用起来还是有些不方便的地方
public class GalleryTabActivityDemo extends GalleryTabactivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setDelegate(new SliderBarActivityDelegateImpl());
        for (int i = 0; i < 14; i++) {
            Intent intent;
            if (i % 2 == 0)
                intent = new Intent(this, DemoActivity1.class);
            else
                intent = new Intent(this, DemoActivity2.class);
            this.addTab("title" + i, android.R.drawable.star_on, intent);
        }
//必须在addTab后调用commit, 有点麻烦, 将来会找更好的办法
        super.setup();
    }
//可自定义切换tab时触发的操作
    private class SliderBarActivityDelegateImpl extends
            SliderBarActivityDelegate {
        protected void onTabChanged(int tabIndex) {
            Log.d("onTabChanged", "" + tabIndex);
        }
    }
}
最近工作比较忙,没太多时间学习android,将来会慢慢改善, 先凑合用, 抛块砖先, 各位有玉的使劲砸, 金条也行
 下载
			posted @ 
2010-05-13 15:46 小强 阅读(2176) | 
评论 (0) | 
编辑 收藏