android - 将横幅放在选项卡主机下方,仅用于一项 Activity

标签 android android-layout

是否可以将横幅放在选项卡主机下方,并且在该横幅中有两个按钮,我想从当前可见的 Activity 中访问这两个按钮???

例如有两个xml文件,一个是tab-host,另一个是activity xml文件。在 tab-host xml 文件中我写了这样的代码

       <?xml version="1.0" encoding="utf-8"?>

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

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

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/seekBar1"
        android:background="#FFB5C5"
        android:gravity="center_horizontal"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
        android:text="No track info available..."
        android:textColor="@android:color/black" />
</LinearLayout>

现在,如果我想将横幅放在选项卡主机下方,我必须在此文件中为该横幅编写代码...

现在但主要问题是在横幅中有两个按钮正在被具有的 Activity 访问

     setContentView(R.layout.activity);

不是

      setContentView(R.layout.tabhost);

所以我不会从

访问横幅
      setContentView(R.layout.activity);

那么谁能建议我怎么做那件事

下面是图片

enter image description here

你可以看到横幅在选项卡主机的下方

现在我想访问第一个 Activity 的横幅..... o

最佳答案

你可以做类似的事情。

  1. 将创建横幅的代码放入 TabActivity 并点击它。
  2. 仅在您想要的 Activity 中显示横幅,否则在其他 Activity 中将其可见性设置为“GONE”。
  3. 完成。

通过上面的解释,您可以只看到 Banner 或您想要的 Activity,并从该 Activity 中实现按钮的点击。

希望你明白我的意思。

欢迎提出任何意见。

关于android - 将横幅放在选项卡主机下方,仅用于一项 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14446606/

相关文章:

android - 取消使用 ProgressDialog 的 AsyncTask

android - 使用Whatsapp同步Android联系人列表中新插入的联系人以获取链接

android - 使用 ListView 时如何修复底部标签栏

android - WebRTC 本地信令服务器

显示不规则行为的 Android Fragments

java - 如何摆脱 Android 中的口是心非?

android - Cards Stack RecyclerView - Android 库

android - 如何对齐重叠两个布局的屏幕按钮中心

android - 使用 Crosswalk 应用程序进行 Appium 测试

Android - 在 RecyclerView 中重新创建自定义动态生成的复合 View ,导致性能不佳