列表活动Android的自定义布局 [英] Custom layout for a list activity Android

查看:57
本文介绍了列表活动Android的自定义布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多类似的问题,但是我没有找到对我有帮助的答案,所以这是我的问题.我已经做到了:

I know there is a lot of similiar questions, but I didn't find the answer that would help me, so this is my question. I have managed to do this:

但是我想要的是:

所以我想要一个固定的按钮在屏幕底部.我的布局是ListActivity的自定义布局,看起来像这样:

So I want a fixed button at the bottom of the screen. And my layout is a custom layout for a ListActivity and it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<RelativeLayout
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    >
 <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:text="Delete" />

<TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_toRightOf="@+id/button1"
    android:text="@+id/label"
    android:gravity="center"
    android:textSize="20px" >
</TextView>

<ImageButton 
    android:id="@+id/rightArrow"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:background="@null"
    android:layout_alignParentRight="true"
    android:src="@drawable/right_arrow" 
    />

推荐答案

您粘贴的内容看起来像是列表行的自定义布局,而不是ListActivity.

What you've pasted looks like a custom layout for the list rows, not the ListActivity.

从Android文档中找到此处:

From the Android documentation found here:

屏幕布局

ListActivity具有默认布局,该布局由屏幕中心的单个全屏列表组成.但是,如果需要,可以通过使用onCreate()中的setContentView()设置自己的视图布局来自定义屏幕布局.为此,您自己的视图必须包含ID为"@android:id/list"的ListView对象. (或列出是否在代码中)

ListActivity has a default layout that consists of a single, full-screen list in thecenter of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)

这篇关于列表活动Android的自定义布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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