它是变现在Android?它是、现在、Android

2023-09-12 04:30:56 作者:愿得一人心

我刚刚开始工作在Android上。是否有可能实现下面的屏幕能否请你给我一个提示:

I've just started working on Android. Could you please give me a tip if it's possible to realize the following screen:

https://m.xsw88.com/allimgs/daicuo/20230912/5386.png

在左侧有列表视图,在右侧有TabView的,在每个选项卡列表视图。 如果它`可能的,什么要素和活动应该怎么使用?

In the left side there is listview and in the right there is TabView with listviews in each tab. And if it`s possible, what elements and activities should I use?

推荐答案

的main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ListView
        android:id="@+id/left_list"
        android:layout_width="100dip"
        android:layout_height="wrap_content" />
    <TabHost
        android:id="@+id/tab_host"
        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">
                <ListView
                    android:id="@+id/listview1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
                <ListView
                    android:id="@+id/listview2"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
                <ListView
                    android:id="@+id/listview3"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" />
            </FrameLayout>
        </LinearLayout>
    </TabHost>
</LinearLayout>

row.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/row_text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="5dip" />

package com.stackoverflow.q5747834;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TabHost;

public class ListViewsGalore extends Activity
{
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    List listContents = new ArrayList();
    listContents.add("one");
    listContents.add("two");
    listContents.add("three");
    listContents.add("four");
    listContents.add("five");
    listContents.add("six");
    listContents.add("seven");
    listContents.add("eight");
    listContents.add("nine");
    listContents.add("ten");
    listContents.add("eleven");
    listContents.add("twelve");
    listContents.add("thirteen");
    listContents.add("fourteen");
    listContents.add("fifteen");
    listContents.add("sixteen");
    listContents.add("seventeen");
    listContents.add("eighteen");
    listContents.add("nineteen");
    listContents.add("twenty");

    ListView leftList = (ListView) findViewById(R.id.left_list);
    leftList.setAdapter(new ArrayAdapter(this, R.layout.row, listContents));

    ListView listview1 = (ListView) findViewById(R.id.listview1);
    listview1.setAdapter(new ArrayAdapter(this, R.layout.row, listContents));

    ListView listview2 = (ListView) findViewById(R.id.listview2);
    listview2.setAdapter(new ArrayAdapter(this, R.layout.row, listContents));

    ListView listview3 = (ListView) findViewById(R.id.listview3);
    listview3.setAdapter(new ArrayAdapter(this, R.layout.row, listContents));

    TabHost mTabHost = (TabHost) findViewById(R.id.tab_host);
    mTabHost.setup();

    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.listview1));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.listview2));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.listview3));

    mTabHost.setCurrentTab(0);
  }
}