Windows下字符编码转换

2020-11-27 23:26

阅读:462

标签:tabhost

有时候经常使用别人用Tabhost+其它的实现demo。单纯利用Tabhost该如何使用呢?

下面看例子:

public class MainActivity extends TabActivity {
	public TabHost tabHost;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 获取对象
		tabHost = getTabHost();
		tabHost.addTab(tabHost.newTabSpec("index").setIndicator("实时新闻")
				.setContent(new Intent(this, IndexActivity.class)));
		tabHost.addTab(tabHost.newTabSpec("center").setIndicator("我的空间")
				.setContent(new Intent(this, MiddleActivity.class)));
		tabHost.addTab(tabHost.newTabSpec("self").setIndicator("设置")
				.setContent(new Intent(this, LastActivity.class)));
		// 指定的当前的tab
		// 通过索引指定 索引从0开始
		// 即一开始要显示的是哪一页
		tabHost.setCurrentTab(0); // 从零开始
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
}
二、效果图

soscw.com,搜素材


(2)Tabhost选项卡置于底部的例子

采用LinearLayout布局,设置Weight属性就可以将选项卡位于底部

1、xml布局文件

2、MainActivity

public class MainActivity extends ActivityGroup
{
    private TabHost mTabHost;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initTabs();
    }

    private void initTabs()
    {
        mTabHost = (TabHost) findViewById(R.id.tabhost);
        mTabHost.setup(this.getLocalActivityManager());
        
        Intent intent = new Intent(this, HomepageActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec("Tab1")
                .setIndicator(getString(R.string.homepage_indicator), getResources().getDrawable(R.drawable.homepage_indicator_selector))
                .setContent(intent));
       
        intent = new Intent(this, BillboardActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec("Tab2")
                .setIndicator(getString(R.string.billboard_indicator), getResources().getDrawable(R.drawable.billboard_indicator_selector))
                .setContent(intent));
        
        intent = new Intent(this, MyLotteryActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec("Tab3")
                .setIndicator(getString(R.string.mylottery_indicator), getResources().getDrawable(R.drawable.mylottery_indicator_selector))
                .setContent(intent));
        
        intent = new Intent(this, MoreActivity.class);
        mTabHost.addTab(mTabHost.newTabSpec("Tab4")
                .setIndicator(getString(R.string.more_indicator), getResources().getDrawable(R.drawable.more_indicator_selector))
                .setContent(intent));
    }
}
3、效果图
soscw.com,搜素材


Windows下字符编码转换,搜素材,soscw.com

Windows下字符编码转换

标签:tabhost

原文地址:http://blog.csdn.net/kusey/article/details/25980323

上一篇:winform 分页

下一篇:winform 加密 解密


评论


亲,登录后才可以留言!