【问题标题】:Android Listview and Focus item through TrackBallAndroid Listview 和 Focus item 通过 TrackBall
【发布时间】:2011-05-18 18:26:45
【问题描述】:

我有 listview ,每行包含 5 个按钮,我可以使用 tackball 移动该行,但我无法集中该行中的按钮,我该怎么做,请帮助我。

我已经给出了列表视图的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:orientation="horizontal"
    android:layout_gravity="center"
    android:gravity="center"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="60dp">
    <LinearLayout
        android:layout_marginTop="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginBottom="5dp"
        android:layout_width="310dp"
        android:layout_height="fill_parent"
        android:background="@drawable/outer">
        <LinearLayout
            android:layout_width="wrap_content"
            android:gravity="center"
            android:clickable="true"
            android:layout_height="fill_parent">
            <TextView
                android:paddingLeft="5dp"
                android:paddingRight="10dp"
                android:textColor="#000000"
                android:textSize="12sp"
                android:text="Billing "
                android:id="@+id/TextView01"
                android:layout_width="140dip"
                android:layout_height="wrap_content" />
            <LinearLayout
                android:layout_height="fill_parent"
                android:gravity="center_vertical"
                android:layout_width="wrap_content">
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:id="@+id/layout_rank_a"
                    android:gravity="center"
                    android:clickable="true"
                    android:layout_height="fill_parent">
                    <Button
                        android:background="@drawable/rank_a"
                        android:id="@+id/rank_a"
                        android:clickable="false"
                        android:layout_width="30dp"
                        android:layout_height="wrap_content" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:id="@+id/layout_rank_b"
                    android:gravity="center"
                    android:clickable="true"
                    android:layout_height="fill_parent">
                    <Button
                        android:layout_marginLeft="3dp"
                        android:background="@drawable/rank_b"
                        android:id="@+id/rank_b"
                        android:layout_width="30dp"
                        android:clickable="false"
                        android:layout_height="30dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:id="@+id/layout_rank_c"
                    android:gravity="center"
                    android:clickable="true"
                    android:layout_height="fill_parent">
                    <Button
                        android:layout_marginLeft="3dp"
                        android:background="@drawable/rank_c"
                        android:id="@+id/rank_c"
                        android:layout_width="30dp"
                        android:clickable="false"
                        android:layout_height="30dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:id="@+id/layout_rank_d"
                    android:clickable="true"
                    android:gravity="center"
                    android:layout_height="fill_parent">
                    <Button
                        android:layout_marginLeft="3dp"
                        android:background="@drawable/rank_d"
                        android:id="@+id/rank_d"
                        android:layout_width="30dp"
                        android:clickable="false"
                        android:layout_height="30dp" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:id="@+id/layout_rank_f"
                    android:gravity="center"
                    android:clickable="true"
                    android:layout_height="fill_parent">
                    <Button
                        android:layout_marginLeft="3dp"
                        android:background="@drawable/rank_f"
                        android:id="@+id/rank_f"
                        android:layout_width="30dp"
                        android:clickable="false"
                        android:layout_height="30dp" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

【问题讨论】:

    标签: android


    【解决方案1】:

    尝试使用相对布局,而不是使用 10 LinearLayout。它可用于将按钮放置在您想要的任何位置。在this page 上阅读它。这也应该使所有按钮都可用于轨迹球。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-16
      • 2013-05-05
      • 2016-11-06
      • 1970-01-01
      相关资源
      最近更新 更多