如何使用自定义iPhone选项卡FragmentActivity? [英] How to use custom iPhone tab in FragmentActivity?

查看:261
本文介绍了如何使用自定义iPhone选项卡FragmentActivity?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android的新的,我试图创建使用FragmentActivity从codeS,我在网上找到一个标签。
http://thepseudo$c$cr.word$p$pss.com/2011/10/04/android-tabs-the-fragment-way/

I am new in Android and I tried to create a tab using FragmentActivity from codes that I found online. http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

这是我的FragmentActivity http://pastie.org/pastes/5170802/text?关键= jhowuevxe2fshlwu5tisg

This is my FragmentActivity http://pastie.org/pastes/5170802/text?key=jhowuevxe2fshlwu5tisg

我想用一个使用图像和文本自定义布局。

I would like to use a custom layout that uses an image and text.

//tab_indicator.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dip"
android:layout_height="55dip"    
android:layout_weight="1"
android:orientation="vertical"
android:background="@drawable/tab_indicator"
android:padding="5dp">

<ImageView android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:src="@drawable/icon"/> 

<TextView android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true"
    style="?android:attr/tabWidgetStyle"/>
</RelativeLayout>

我发现了一个类似的问题在这里:创建FragmentActivity 自定义选项卡,但我couldn '吨弄清楚如何应用在我的codeS的解决方案。谁能教教我怎么样?谢谢你。

I found a similar question here : create custom tab in FragmentActivity but I couldn't figure it out how to apply the solution in my codes. Can someone teach me how? Thank you.

更新:

我设法在我的codeS膨胀的自定义布局。但我面临的另一个错误。这是我最新codeS http://pastie.org/pastes/5187362/text ?关键= 74r87diquysvruwsam1tq 调整,以FragmentActivity,从AdilSoomro的 http://adilsoomro.blogspot.com/2011/06/iphone-like-tabs-in-android.html codeS(使用TabActivity)与一些参考从

I managed to inflate the custom layout in my codes. But I faced another error. This is my latest codes http://pastie.org/pastes/5187362/text?key=74r87diquysvruwsam1tq tweaked to FragmentActivity, from AdilSoomro http://adilsoomro.blogspot.com/2011/06/iphone-like-tabs-in-android.html codes (which uses TabActivity) with some references from

  • http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
  • http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

我最近codeS成功夸大这样的布局,设置 HTTP: //pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmw 其布局(tab_indicator.xml)

My latest codes successfully inflate the layout like this, with the setting http://pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmw for its layout (tab_indicator.xml)


但我需要调整我的标签底部。当我将它对准下方,code layout_gravity =底图形化布局的工作,但是当我运行它,我相对布局的背景充满整个屏幕,这样的code的 http://pastie.org/pastes/5187445/text?key=6dz2tsiggey9se51d2thtq

有人可以告诉我,我做错了什么?

can someone tell me what I did wrong?

推荐答案

解决它!最后!测试我提及的其他资源后,我意识到,在layout_alignParentBottom RelativeLayout的不给任何结果。因此,我试图对准TabWidget底部,而是和它的工作!

Solved it! Finally! After testing other resources that I referred to, I realized that layout_alignParentBottom in RelativeLayout does not give any outcome. Hence I tried aligning the TabWidget to the bottom instead, and it worked!

这是我的main.xml中包含TabHost和TabWidget。
http://pastie.org/pastes/5188297/text?key=lqfp3jnofs5kgsvslm3yg

This is my main.xml that contain TabHost and TabWidget. http://pastie.org/pastes/5188297/text?key=lqfp3jnofs5kgsvslm3yg

请在tab_indicator.xml /文本和图像像这样设置: HTTP: //pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmw

Keep the tab_indicator.xml / the settings for the text and image like this : http://pastie.org/pastes/5187408/text?key=qxxa5xxrhsburebllyhmw

这是使用FragmentActivity的定制iPhone标签:

And here is the a custom iPhone tab that uses FragmentActivity :

P / S:很抱歉,如果我的Java文件是混乱的,我是新的,如果有什么我做错了,你告诉我。

P/S : Sorry if my Java file is confusing, I'm new and if there is anything I did wrong, do tell me.

这篇关于如何使用自定义iPhone选项卡FragmentActivity?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆