如何处理android中listview上项目的事件点击按钮 [英] how to handle event click button of item on listview in android

查看:82
本文介绍了如何处理android中listview上项目的事件点击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您阅读本主题

我在Android上有列表视图。

项目有组件包括1个TextView和2个按钮(+和 - )

我想点击按钮+,textview是数字++)

点击按钮 - ,textview是数字 - )

如何处理点击2按钮+和 - ?

所以,这是我的代码

  public 查看getView( final   int  groupPosition,View convertView,ViewGroup parent){
if (convertView == null){
convertView = inflater.inflate(R.layout.modul_item,null);
}

TextView tv =(TextView)convertView.findViewById(R.id.modul_title);
tv.setText(modul_overviewActivity.getvalue()。get(groupPosition));

Button Button_1 =(Button)convertView.findViewById(R.id.button1);
Button_1.setOnClickListener( new OnClickListener(){

public void onClick(查看v){
// TODO
}

});
按钮Button_2 =(按钮)convertView.findViewById(R.id.button2);

return convertView;
}





但是,列表浏览显示速度很慢

请帮助我!

Thansk非常抱歉我的英语

解决方案

将android:focusable =false保存到按钮。 / BLOCKQUOTE>

Hi and thanks for read this topic
I have list view on android.
Item have components include 1 TextView and 2 buttons (+ and - )
I want to click button + , textview is "number++")
click button - , textview is "number--")
How to handle click 2 button + and - ?
So, this my code for this

public View getView(final int groupPosition, View convertView, ViewGroup parent) {
         if (convertView == null) {
              convertView = inflater.inflate(R.layout.modul_item, null);
         }

         TextView tv = (TextView) convertView.findViewById(R.id.modul_title);
         tv.setText(modul_overviewActivity.getvalue().get(groupPosition));

         Button Button_1 = (Button)convertView.findViewById(R.id.button1);
         Button_1.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
                     //TODO
                }

            });
         Button Button_2 = (Button)convertView.findViewById(R.id.button2);

    return convertView;
}



however, show very slow on listview
plz help me!
Thansk so much and sorry about my english

解决方案

keep android:focusable="false" to the button.


这篇关于如何处理android中listview上项目的事件点击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆