Windows下字符编码转换

有时候经常使用别人用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;
	}
}

二、效果图

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

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

1、xml布局文件

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1.0" >
        </FrameLayout>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </TabWidget>
    </LinearLayout>

</TabHost>

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、效果图

Windows下字符编码转换,布布扣,bubuko.com

时间: 2024-08-06 19:45:31

Windows下字符编码转换的相关文章

windows下go编码转换问题

github上有两个package做编码转换,都是基于iconv,用到了cgo,在linux下没有问题,在windows下用,非常麻烦.采用mingw安装libiconv也不行,一直提示找不到libiconv方法. 最终找到一个官方实现(纯go实现):https://code.google.com/p/go/source/checkout?repo=text gbk转utf-8示例: func gbk2utf8(str byte[]) ([]byte, error) { return iouti

windows下字符编码的转化函数

//GB2312到UTF-8的转换static int GB2312ToUtf8(const char* gb2312, char* utf8){int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);wchar_t* wstr = new wchar_t[len+1];memset(wstr, 0, len+1);MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);len

iconv字符编码转换

转自 http://blog.csdn.net/langresser_king/article/details/7459367 iconv(http://www.gnu.org/software/libiconv/)是一个开源的字符编码转换库,可以"方便"的完成几乎所有的编码转换工作.说简单是因为,它常用的接口就三个,iconv_open  iconv   iconv_close,但是即便是只有三个接口,要想使用正确也不容易.这里把一些基本概念和使用细节记录下来,希望能成为一篇最实用的

erlang中字符编码转换(转)

转自:http://www.thinksaas.cn/group/topic/244329/ 功能说明: erlang中对各种语言的编码支持不足,此代码是使用erlang驱动了著名的iconv编码库来对字符进行编码转换处理. 文件说明: iconv_erl.c和iconv.h 是erlang字符编码模块的driver,作用是对iconv进行封装.编译后生成iconv_erl.dll,供iconv.erl使用. iconv_makefile.win32 windows上编译iconv_erl.dl

php字符编码转换之gb2312转为utf8(转)

在php中字符编码转换我们一般会用到iconv与mb_convert_encoding进行操作,但是mb_convert_encoding在转换性能上比iconv要差很多哦.string iconv ( string in_charset, string out_charset, string str ) 注意:第二个参数,除了可以指定要转化到的编码以外,还可以增加两个后缀://TRANSLIT 和 //IGNORE,其中 //TRANSLIT 会自动将不能直接转化的字符变成一个或多个近似的字符

php 字符编码转换函数 iconv mb_convert_encoding比较

在使用PHP处理字符串时,我们经常会碰到字符编码转换的问题,你碰到过iconv转换失败吗? 发现问题时,网上搜了搜,才发现iconv原来有bug ,碰到一些生僻字就会无法转换,当然了配置第二个参数时,可以稍微弥补一下默认缺陷,不至于无法转换是截断,用法如下 iconv(“UTF-8″,”GB2312//IGNORE”,$data) ; 这样碰到生僻字转换失败时,它就会忽略失败,继续转换下面的内容,这算解决问题的一个办法,不过为了确保转换的成功率,我们可以用另一个转换函数(mb_convert_e

ASP中有关字符编码转换的几个有用函数

ASP中有关字符编码转换的几个有用函数 <%1.'UTF转GB---将UTF8编码文字转换为GB编码文字function UTF2GB(UTFStr) for Dig=1 to len(UTFStr)   '如果UTF8编码文字以%开头则进行转换  if mid(UTFStr,Dig,1)="%" then      'UTF8编码文字大于8则转换为汉字    if len(UTFStr) >= Dig+8 then        GBStr=GBStr & Con

cocos2d-x教程2:在windows下如何批量转换pvr,ccz为png或jpg

这是一个很常见的功能,但是找了全网,居然找不到,于是借鉴别人的批处理文件,改了下,就可以把整个目录的全部一次批量转换. 将这个bat文件暂定为,myConvert.bat,执行时就把这个bat文件放到要转换的目录,然后双击bat,就可以啦.下面把bat文件贴出来: rem path " "里面内容替换为TexturePacker的安装路径,将bat文件放在图片文件夹直接运行就可以了 @ech off path %path%;"c:\TexturePacker\bin"

python基础 字符编码转换

python2 1 #python2上所有的字符编码都需要先decode到unicode,再从unicode encode到目标编码 2 str_utf8 = "我就是我" 3 print("str_utf-8:我就是我:",str_utf8) 4 #将utf-8转换为unicode 5 str_utf8_to_unicode = str_utf8.decode("utf-8") 6 print(str_utf8_to_unicode) 7 #将