在列表视图中选中复选框时,按钮中的文本从中心向左移动

发布于 2025-01-06 12:28:19 字数 2930 浏览 2 评论 0原文

我创建了一个屏幕,其中包含表格布局中的三个水平按钮和列表视图。 每当我单击列表视图中的复选框时,按钮中的文本就会向左移动。 请解决问题。 请参阅屏幕布局代码和屏幕截图。

<RelativeLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">

         <TableLayout android:id="@+id/TableLayout01"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:layout_alignParentBottom="true">

             <TableRow android:id="@+id/TableRow01" 
                                android:layout_width="match_parent" 
                                android:layout_height="fill_parent" 
                                android:background="@color/list_select" android:weightSum="3">

          <Button android:layout_width="wrap_content"
                  android:layout_height="wrap_content" 
                  android:id="@+id/set" 
                  android:text="@string/button_settings_done" 
                  android:layout_marginTop="@dimen/button_settings_margin_top" 
                  android:textColor="@color/buttonColor" 
                  android:textStyle="bold" 
                  android:typeface="serif" android:layout_weight="1">

          </Button>
          <Button android:layout_width="wrap_content" 
                  android:layout_height="fill_parent"
                  android:text="@string/button_settings_cancel"
                  android:id="@+id/cancel"
                  android:layout_marginTop="@dimen/button_settings_margin_top"
                  android:textColor="@color/buttonColor"
                  android:textStyle="bold" 
                  android:typeface="serif" android:layout_weight="1"></Button>


          <Button
              android:id="@+id/delete"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="@dimen/button_settings_margin_top"
              android:text="@string/button_settings_delete"
              android:textColor="@color/buttonColor"
              android:textStyle="bold"
              android:typeface="serif" android:layout_weight="1"/>

          <ListView
              android:id="@android:id/list"
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:layout_above="@+id/TableLayout01"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true" android:cacheColorHint="@color/transparent" android:divider="@color/list_select" android:dividerHeight="@dimen/list_settings_divider_height">

          </ListView>

屏幕截图 检查复选框之前 检查后

I have created a screen which consist of three horizontal button in a table layout and a list view.
Whenever i click on a check box present in the list view the text present in the button shifts to the left.
Kindly resolve the issue.
Please refer the screen layout code and the screen shots for same.

<RelativeLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">

         <TableLayout android:id="@+id/TableLayout01"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:layout_alignParentBottom="true">

             <TableRow android:id="@+id/TableRow01" 
                                android:layout_width="match_parent" 
                                android:layout_height="fill_parent" 
                                android:background="@color/list_select" android:weightSum="3">

          <Button android:layout_width="wrap_content"
                  android:layout_height="wrap_content" 
                  android:id="@+id/set" 
                  android:text="@string/button_settings_done" 
                  android:layout_marginTop="@dimen/button_settings_margin_top" 
                  android:textColor="@color/buttonColor" 
                  android:textStyle="bold" 
                  android:typeface="serif" android:layout_weight="1">

          </Button>
          <Button android:layout_width="wrap_content" 
                  android:layout_height="fill_parent"
                  android:text="@string/button_settings_cancel"
                  android:id="@+id/cancel"
                  android:layout_marginTop="@dimen/button_settings_margin_top"
                  android:textColor="@color/buttonColor"
                  android:textStyle="bold" 
                  android:typeface="serif" android:layout_weight="1"></Button>


          <Button
              android:id="@+id/delete"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="@dimen/button_settings_margin_top"
              android:text="@string/button_settings_delete"
              android:textColor="@color/buttonColor"
              android:textStyle="bold"
              android:typeface="serif" android:layout_weight="1"/>

          <ListView
              android:id="@android:id/list"
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:layout_above="@+id/TableLayout01"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true" android:cacheColorHint="@color/transparent" android:divider="@color/list_select" android:dividerHeight="@dimen/list_settings_divider_height">

          </ListView>

Screen shots
Before checking checkbox
After checking

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你对谁都笑 2025-01-13 12:28:19

这很奇怪,但试试这个......
当您单击列表视图中存在的复选框时..在 OnClick 方法上..再次设置这些按钮的文本..就像

btn1.setText("Done");
btn2.setText("Cancel");
btn3.setText("Delete");

在我的情况下效果很好..我遇到了同样的问题。
希望这对你有帮助

its weird but try this...
when you are clicking on a check box present in the list view..there on OnClick method..set the text of these button again..like

btn1.setText("Done");
btn2.setText("Cancel");
btn3.setText("Delete");

It worked very well in my case..I had the same problem.
hope this helps you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文