首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android上的Master-detail布局

Android上的Master-detail布局
EN

Stack Overflow用户
提问于 2012-04-03 17:32:23
回答 3查看 3.1K关注 0票数 1

我有一个应用程序,其中一个选项卡上有一个任务列表。我的意图是,当我单击该列表中的一个元素时,我希望看到该任务的详细信息。是否可以在同一页中查看该任务的列表和详细信息?我正在使用Eclipse。

EN

回答 3

Stack Overflow用户

发布于 2012-04-03 17:33:56

你可以通过摆弄视图和它们的可见性/大小来自己编写代码。或者您可以使用片段:http://developer.android.com/guide/topics/fundamentals/fragments.html

票数 0
EN

Stack Overflow用户

发布于 2012-04-03 17:37:43

您可以在列表视图项目上打开PopupWindow,单击并显示所选项目的详细信息。要打开项目的PopupWindow,请单击see

票数 0
EN

Stack Overflow用户

发布于 2012-04-03 17:48:22

如果出于某种原因,你不想使用片段(例如,你永远不会重用这个视图),你也可以这样做--简单而简单:

这将是您的拆分屏幕布局splitscreen.xml

代码语言:javascript
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:id="@+id/task_list_wrap"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="2dp" >

        <ListView
            android:id="@+id/task_list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:overScrollMode="never" >
        </ListView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/task_details"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/task_details_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="this is description text" />
    </LinearLayout>

</LinearLayout>

在活动中单击任务列表时,您可以更改任务详细信息面板的内容,如下所示:

代码语言:javascript
复制
setContentView(R.layout.splitscreen);
ListView taskList= (ListView) findViewById(R.id.task_list);
TextView taskDescription = (TextView) findViewById(R.id.task_details_description);
taskList.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view,
        int position, long id) {
        int selectedTask = position;
        updateTaskDescription(selectedTask, taskDescription);
    }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9990603

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档