首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过TrackBall实现安卓Listview和焦点项目

通过TrackBall实现安卓Listview和焦点项目
EN

Stack Overflow用户
提问于 2011-05-18 17:25:23
回答 1查看 486关注 0票数 0

我有一个列表视图,每行包含5个按钮,我可以使用阻击球来移动行,但我不能将焦点放在行中的按钮上,我该如何做,请帮助我。

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

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

发布于 2011-05-18 18:26:45

尝试使用相对布局,而不是使用10 LinearLayout。它可以用来把按钮放在任何你想要的地方。在this page上阅读它。此外,这应该使所有的按钮可用于轨迹球。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6042491

复制
相关文章

相似问题

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