zoukankan      html  css  js  c++  java
  • listView中的button控件获取索引

    1、在listitem中初始化button的时候,给该button添加一个setTag方法,将此时的索引值传进去,然后在button的onclick事件中调用view的getTag方法,即可将listitem的索引读出来,代码如下:

        tagButton.setTag(position); 此处的tagButton就是定义的button,Position是view里边的位置。

    2、初始化button的时候通过setTag方法传入一个item的索引值

         private OnClickListener tagButtonOnClick = new OnClickListener() {    

               public void onClick(View v) {  

                 final int index = (Integer) v.getTag();  

          }
        }
     index就是点击button所在Item中的位置,通过这个位置就可以得到Item中的值。
  • 相关阅读:
    isalnum()方法
    index()方法
    find()方法
    expandtabs()方法
    endswith()方法
    encode()方法
    bytes.decode()方法
    count()方法
    center()方法
    capitalize()方法
  • 原文地址:https://www.cnblogs.com/dj168/p/3838199.html
Copyright © 2011-2022 走看看