久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='0IUgV'></tfoot><legend id='0IUgV'><style id='0IUgV'><dir id='0IUgV'><q id='0IUgV'></q></dir></style></legend>

  • <small id='0IUgV'></small><noframes id='0IUgV'>

      <i id='0IUgV'><tr id='0IUgV'><dt id='0IUgV'><q id='0IUgV'><span id='0IUgV'><b id='0IUgV'><form id='0IUgV'><ins id='0IUgV'></ins><ul id='0IUgV'></ul><sub id='0IUgV'></sub></form><legend id='0IUgV'></legend><bdo id='0IUgV'><pre id='0IUgV'><center id='0IUgV'></center></pre></bdo></b><th id='0IUgV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0IUgV'><tfoot id='0IUgV'></tfoot><dl id='0IUgV'><fieldset id='0IUgV'></fieldset></dl></div>
      • <bdo id='0IUgV'></bdo><ul id='0IUgV'></ul>

        Android:為 ListView 中的每個項目添加事件偵聽器

        Android: Add event listeners to every item in a ListView(Android:為 ListView 中的每個項目添加事件偵聽器)
          <tfoot id='GAhSa'></tfoot>

          <legend id='GAhSa'><style id='GAhSa'><dir id='GAhSa'><q id='GAhSa'></q></dir></style></legend>

            <small id='GAhSa'></small><noframes id='GAhSa'>

            • <i id='GAhSa'><tr id='GAhSa'><dt id='GAhSa'><q id='GAhSa'><span id='GAhSa'><b id='GAhSa'><form id='GAhSa'><ins id='GAhSa'></ins><ul id='GAhSa'></ul><sub id='GAhSa'></sub></form><legend id='GAhSa'></legend><bdo id='GAhSa'><pre id='GAhSa'><center id='GAhSa'></center></pre></bdo></b><th id='GAhSa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GAhSa'><tfoot id='GAhSa'></tfoot><dl id='GAhSa'><fieldset id='GAhSa'></fieldset></dl></div>

                <tbody id='GAhSa'></tbody>

                  <bdo id='GAhSa'></bdo><ul id='GAhSa'></ul>
                • 本文介紹了Android:為 ListView 中的每個項目添加事件偵聽器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個帶有 ListView 的 Android 應用,列表中的每一行都有一個 TextView 和一個 Button.我想要做的是為 ListView 中的每個 Button 添加一個 OnClickListener,但我不知道如何獲得對每個 Button 的某種引用......誰能給我一個提示?

                  I have an Android app with a ListView, and each row in the list has a TextView and a Button. What I want to do is add an OnClickListener to each Button in the ListView, but I can't figure out how to get some sort of reference to every Button... Can anyone please give me a hint?

                  這是綁定到 ListAdapter 的 XML:

                  Here's my XML that's bound to the ListAdapter:

                  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content">
                  <TextView 
                      android:id="@+id/row_text"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_alignParentLeft="true"
                      android:textSize="18sp">
                  </TextView>
                  <Button
                      android:id="@+id/row_button"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_alignParentRight="true" />
                  </RelativeLayout>
                  

                  我嘗試了類似的方法,但它不起作用:

                  And I tried something like this, but it doesn't work:

                  SimpleCursorAdapter rows = new SimpleCursorAdapter(this, R.layout.row_layout, cursor, from, to);
                  setListAdapter(rows);
                  Button button = (Button) getListAdapter().getView(0, null, getListAdapter()).findViewById(R.id.row_button);
                  button.setOnClickListener(new View.OnClickListener() {
                      @Override public void onClick(View v) {
                          Log.i(TAG, "clicked");
                      }
                  }); 
                  

                  推薦答案

                  不可能使用 SimpleCursorAdapter... 你必須創(chuàng)建自己的適配器.如果您不想編寫自定義適配器,至少嘗試使用新功能增強 SimpleCursorAdapter.例如:

                  It's not possible using SimpleCursorAdapter... you will have to create your own adapter. If you don't want to write a custom Adapter, at least try to enhance the SimpleCursorAdapter with new capabilities. For instance:

                  public class YourAdapter extends SimpleCursorAdapter{
                  
                      public YourAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
                          super(context, layout, c, from, to);
                      }
                  
                      public View getView(int position, View convertView, ViewGroup parent){
                          View view = super.getView(position, convertView, parent);
                          Button button = (Button)view.findViewById(R.id.row_button);
                          button.setOnClickListener(new View.OnClickListener() {
                              @Override public void onClick(View v) {
                                  Log.i(TAG, "clicked");
                              }
                          }); 
                          return view;
                      }
                  }
                  

                  那么,你可以這樣做:

                  SimpleCursorAdapter rows = new YourAdapter(this, R.layout.row_layout, cursor, from, to);
                  setListAdapter(rows);
                  

                  這篇關(guān)于Android:為 ListView 中的每個項目添加事件偵聽器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                  <tfoot id='eQKH0'></tfoot>
                • <small id='eQKH0'></small><noframes id='eQKH0'>

                        <tbody id='eQKH0'></tbody>
                        <legend id='eQKH0'><style id='eQKH0'><dir id='eQKH0'><q id='eQKH0'></q></dir></style></legend>
                        • <bdo id='eQKH0'></bdo><ul id='eQKH0'></ul>

                          1. <i id='eQKH0'><tr id='eQKH0'><dt id='eQKH0'><q id='eQKH0'><span id='eQKH0'><b id='eQKH0'><form id='eQKH0'><ins id='eQKH0'></ins><ul id='eQKH0'></ul><sub id='eQKH0'></sub></form><legend id='eQKH0'></legend><bdo id='eQKH0'><pre id='eQKH0'><center id='eQKH0'></center></pre></bdo></b><th id='eQKH0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eQKH0'><tfoot id='eQKH0'></tfoot><dl id='eQKH0'><fieldset id='eQKH0'></fieldset></dl></div>

                          2. 主站蜘蛛池模板: 久久亚洲91 | 91久久婷婷| 99热国产免费 | 精品久久久久久久久久 | 日韩一区二区三区在线观看 | 色橹橹欧美在线观看视频高清 | 国产人成在线观看 | 国产在线视频在线观看 | 久久久网| 亚洲精品三级 | 日日夜夜天天 | 精品欧美乱码久久久久久1区2区 | 在线观看免费av片 | 精品一区二区三区四区 | 亚洲精品国产成人 | 日韩精品免费一区二区在线观看 | 久久r久久 | 高清av在线 | 久久99精品国产 | 久草新在线 | aaa综合国产 | 久久综合激情 | 久久99精品久久久久久琪琪 | 欧美精品久久一区 | 亚洲精品永久免费 | 久久精品视频91 | 91国内产香蕉 | 亚洲一区二区在线免费观看 | 九七午夜剧场福利写真 | 色网站在线| 奇米av| 国产伦精品一区二区三区视频金莲 | 99re热精品视频 | 国产成人综合亚洲欧美94在线 | 亚洲精品9999 | 999www视频免费观看 | 欧美精品网站 | 国产乱码精品一区二区三区忘忧草 | 夜夜爽夜夜操 | 黄色片在线 | 黄色网址免费看 |