解决方案 »

  1.   


     <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >        <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >            <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:paddingBottom="50dp" 
                    >
                </FrameLayout>
                
                <TabWidget
                    android:layout_alignParentBottom="true"
                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" >
                </TabWidget>
            </RelativeLayout>
        </TabHost>
     TabHost tabHost = getTabHost(); TabSpec tabSpec1 = tabHost.newTabSpec("tag1");
    TabSpec tabSpec2 = tabHost.newTabSpec("tag2"); tabSpec1.setIndicator(getIndicator(R.drawable.tab_main_nav_me, "个人中心"));
    tabSpec2.setIndicator(getIndicator(R.drawable.tab_main_nav_book, "新书"));

    Intent tabSpec1Intent = new Intent(this, MyDouActivity.class);
    Intent tabSpec2Intent = new Intent(this, NewBookActivity.class);

    tabSpec1.setContent(tabSpec1Intent);
    tabSpec2.setContent(tabSpec2Intent);

    tabHost.addTab(tabSpec1);
    tabHost.addTab(tabSpec2);/**
     * 自定义的VIew
     * @param resId
     * @param charSequence
     * @return
     */
    public View getIndicator(int resId, CharSequence charSequence) {
    View view = View.inflate(getApplicationContext(), R.layout.mydou_tapspec, null);
    ImageView imageView = (ImageView) view.findViewById(R.id.iv_mydou_tapspac_image);
    TextView textView = (TextView) view.findViewById(R.id.tv_mydou_tapspec_text);
    imageView.setImageResource(resId);
    textView.setText(charSequence);

    return view;
    }