【问题标题】:New Layout between the existing layout现有布局之间的新布局
【发布时间】:2011-08-09 08:33:09
【问题描述】:

我已经制作了一个布局,我想从现有的 xml 文件中设置另一个布局。这可能吗?

见以下代码:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView 
            android:id="@+id/textview1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="this is a tab" />
        <TextView 
            android:id="@+id/textview2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="this is another tab" />
        <TextView 
            android:id="@+id/textview3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="this is a third tab" />
    </FrameLayout>
</LinearLayout>

现在我想在 frameLayout 中设置 Layout` 这怎么可能?

谢谢。

【问题讨论】:

  • 你想动态添加布局吗(意味着在活动中)?
  • 不,我已经在 Xml 文件中创建了 Both 布局,对于 Main Activity 的公共视图,我想使用该技巧。我想在活动调用中调用另一个内部视图。 . .怎么可能?
  • 请检查我已经更新了我给出的代码的问题

标签: android android-emulator android-layout android-widget


【解决方案1】:

只需使用您的第二个布局创建另一个 Activity,然后使用 startActivity() 启动第二个 Activity。

【讨论】:

    【解决方案2】:

    您没有提供任何代码,但如果您在 xml 中有 2 个布局并且第一个应该包含第二个,请使用 include-tag

    【讨论】:

      猜你喜欢
      • 2015-12-09
      • 2017-05-02
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 2017-12-31
      • 1970-01-01
      相关资源
      最近更新 更多