如何实现在android系统修复栏布局 [英] How to implement a fix bar layout in android

查看:113
本文介绍了如何实现在android系统修复栏布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建这样一个布局:

I want to create a layout like this:

我觉得滚动型是必要的,也许是这样的:

I think the ScrollView is necessary, maybe like this:

<RelativeLayout>
    <RelativeLayout id="fixed">
    </RelativeLayout>
    <ScrollView>
        <RelativeLayout>
            <Button...
            <ListView....
            <Button...
            </RelatievLayout>
    </ScrollView>
</RelativeLayout>

但似乎添加的ListView 滚动型不是好主意。

任何想法做呢?

BTW,不仅有 Button1的将Button2 列表视图外,还有更多的意见,所以我做的不要以为加意见,脚或头部是一个好主意。

BTW, there are not only Button1 and Button2 outside the listview, there are more views, so I do not think add the views as foot or head is a good idea.

推荐答案

第一个想法(没有建议报告):添加的ListView A 里面滚动型是一个坏主意,因为两者都是在默认情况下滚动。你可以使用的的ListView一个的LinearLayout 而不是并创建自定义onClickListener的项目。

First idea (not recommanded): Adding a ListView inside a ScrollView is a bad idea, because both are scrollable by default. You could use a LinearLayout instead of the ListView and create a custom onClickListener for the items.

<Scrollview>
   <Button.../>
   <LinearLayout>
     <items.../>
   </LinearLayout>
</Scrollview>

第二个想法(建议报告)是一去的ListView 并创建延伸 BaseAdapter 自定义适配器返回查看的每一行,并保存数据。这意味着将你的按钮和项目的的ListView 并创建一个自定义的 OnClickListener 和适配器来保存你模型。这是我使用的方法,我会再做一次这样的。

Second idea (recommanded) is to go with one ListView and create a custom Adapter extending BaseAdapter returning the Views for each row and holding the data. This means adding your Buttons and Items to the ListView and create a custom OnClickListener and Adapter to hold you Model. This Is the way I have used and I would do it again this way.

我你的适配器,你需要重写:

I your Adapter, you will need to Override:

getViewTypeCount - 类型不同行布局数

getViewTypeCount - number of types of different row-layouts.

getItemViewType 行的类型。

getView 返回视图的位置,在这里你需要膨胀的布局和设置数据。

getView returning the view for a position, here you need to inflate the layout and set the data.

这是如何创建具有不同类型的行的ListView的一个相关的问题。

This is a related question how to create a ListView with different types of rows.

这篇关于如何实现在android系统修复栏布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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