Android的 - 里面tableLayout列表视图 [英] Android - ListViews inside tableLayout

查看:147
本文介绍了Android的 - 里面tableLayout列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立和应用程序,显示了有组织的数据,所以我在想,基本上是一个 TableLayout 将是一个不错的主意,只是为了让他们在行,所以我不知道什么做的正确方法?我有这个在我的XML

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:方向=垂直>

    < TableLayout
        机器人:ID =@ + ID / tableLayout1
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT>
        <的TableRow>
            <的TextView
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =FILL_PARENT
                机器人:文本=@字符串/你好>
             < / TextView的>

            <的ListView
                机器人:ID =@ + ID / ListView1的
                机器人:layout_width =match_parent
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginLeft =233dp
                机器人:layout_marginTop =44dp>
            < / ListView控件>
        < /的TableRow>
    < / TableLayout>

< / LinearLayout中>
 

那么它只是在 TableLayout 标记和的TableRow 标签会显示一个警告,说:

 这TableLayout布局或它的LinearLayout母公司可能是无用的
 

所以我的理解是,没有拿起 TableLayout 。我该如何解决这一问题?有另一种方式来伊斯利做到这一点?

解决方案
  

所以我的理解是,没有拿起tablelayout。我该如何解决这一问题?有另一种方式来伊斯利做到这一点?

不完全是,渲染器的考虑到TableLayout,但因为皮棉工具检测到你有两个观点时,你只需要一(A 的LinearLayout TableLayout )是警告你,应该删除之一这些布局,因为这将提高性能,同时不影响在网页的功能。

我会加,你有一个单行一个TableLayout。 TableLayout的设计,让他们的内容,它们的列基于其所有的行格式化。跟单排TableLayout和放大器;行一起被作为一个LinearLayout中:

 <的LinearLayout>
    <的LinearLayout>
        < ListView控件>
        < TextView的>
 

由于您的TableLayout不加入任何另外的布局在这种情况下它变得过时,你将获得的资源推动的取出和更换定位的LinearLayout来水平

如果您打算增加更多的的TableRow 的后面,则应该改为删除的LinearLayout 的由于同样的原因 - 那么这将成为其不加入额外的信息视图:你的表格布局将完全负责的布局,所以你还不如让它布局文件的父(记得要加的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android属性,如果你做到这一点)

I'm trying to build and app that shows organized data so I'm thinking that basically a TableLayout would be a good idea, just to keep them in rows, so I'm wondering whats the correct way to do it? I have this in my xml

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

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TableRow>
            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="@string/hello" >
             </TextView>

            <ListView
                android:id="@+id/listView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="233dp"
                android:layout_marginTop="44dp" >
            </ListView>
        </TableRow>
    </TableLayout>

</LinearLayout>

then it's just that the TableLayout tag and TableRow tag displays a warning that says:

"This TableLayout layout or its LinearLayout parent is possibly useless"

so what I understand is that is not picking up the TableLayout. how can I fix this? is there another way to do this easly?

解决方案

so what i understand is that is not picking up the tablelayout. how can i fix this? is there another way to do this easly?

Not quite, the renderer is taking account of the TableLayout but because the lint tool has detected that you have two views when you only need one (A LinearLayout and TableLayout) it is warning you that you should remove one of these layouts as it will boost performance while not effecting the functionality of the page.

I will add, you have a TableLayout with just a single row. TableLayout's are designed to allow their contents to format their columns based upon all of their rows. With a single Row the TableLayout & Row together are acting as a LinearLayout:

<LinearLayout>
    <LinearLayout>
        <ListView>
        <TextView>

Since your TableLayout isn't adding any addition layout in that case it becomes obsolete and you will gain a resource boost from removing it and changing the orientation of LinearLayout to horizontal.

If you're planning to add more TableRow's later, then you should instead remove the LinearLayout for the same reason - it will then become the view which is not adding extra information: your table layout will be entirely responsible for the layout so you might as well make it the parent of the layout file (remember to add xmlns:android="http://schemas.android.com/apk/res/android" attribute to it if you do.)

这篇关于Android的 - 里面tableLayout列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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