隨筆-348  評論-598  文章-0  trackbacks-0
          將具有點(diǎn)擊事件控件的android:focusable屬性置成false就可以了。如下例子是可以既捕捉onItemClick事件(在非checkbox和非button區(qū)域),又可以捕捉onClick等事件。看到網(wǎng)上還有很多人不會,特意共享一下。
          <?xml version="1.0" encoding="utf-8"?>
          <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation
          ="horizontal" android:layout_height="fill_parent"
              android:id
          ="@+id/LinearLayoutGameListItem" android:layout_width="fill_parent"
              android:gravity
          ="center_vertical" android:layout_marginLeft="@dimen/mygamecenter_common_margin"
              android:layout_marginRight
          ="@dimen/mygamecenter_common_margin">
          <CheckBox android:id="@+id/CheckBoxGameListItem"
                      android:focusable
          ="false" android:layout_width="wrap_content"
                      android:layout_height
          ="wrap_content"></CheckBox>
              
          <Button android:text="@string/top" android:id="@+id/ButtonTop"
                  android:textColor
          ="#FFFFFF" android:focusable="false"
                  android:layout_width
          ="wrap_content" android:layout_height="@dimen/game_list_item_button_height"
                  android:layout_marginRight
          ="@dimen/game_list_item_button_margin_right"
                  android:paddingLeft
          ="@dimen/game_list_item_button_padding_left"
                  android:paddingRight
          ="@dimen/game_list_item_button_padding_right"
          android:background
          ="@drawable/button_cool_small_selector"></Button>
          </LinearLayout>


          ---------------------------------------------------------
          專注移動開發(fā)

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2010-10-13 21:16 TiGERTiAN 閱讀(5017) 評論(2)  編輯  收藏 所屬分類: Android

          評論:
          # re: Android/OPhone ListView中如何使用Button,讓onClick和onItemClick事件共存 2012-09-14 16:53 | zealotrouge
          Button驗(yàn)證OK,但是ImageButton用此方法還是不行哦~  回復(fù)  更多評論
            
          # re: Android/OPhone ListView中如何使用Button,讓onClick和onItemClick事件共存[未登錄] 2013-06-13 11:17 | 啊啊
          主站蜘蛛池模板: 景泰县| 双牌县| 昆山市| 讷河市| 东港市| 竹溪县| 邵阳市| 平昌县| 夏邑县| 慈溪市| 靖远县| 峨眉山市| 安龙县| 高雄市| 洛浦县| 浮山县| 白朗县| 富宁县| 宁安市| 阿瓦提县| 普兰县| 连山| 长岛县| 沾益县| 古交市| 浙江省| 贵州省| 神木县| 富川| 北川| 白水县| 聂拉木县| 陆良县| 合山市| 峨边| 昭通市| 宜都市| 普陀区| 通辽市| 香港 | 崇信县|