zoukankan      html  css  js  c++  java
  • ListView中Button事件


    为了解决ListView中Item里的Button独立事件响应,能够採用下面方法:

    在BaseAdapter的getview里加入加粗代码:


    <span style="font-size:14px;">@Override
    	public View getView(int position, View view, ViewGroup arg2) {
    		view = layoutInflater.from(context).inflate(
    				R.layout.sport_user_list_item, null);
    
    		TextView text1 = (TextView) view.findViewById(R.id.user_name);
    		TextView text2 = (TextView) view.findViewById(R.id.user_grade);
    		
    		Button button1 = (Button) view.findViewById(R.id.challenger_btn);
    
    		text1.setText("姓名");
    		text2.setText("等级");
    
    		String user = sportUserList.get(position).getUser();
    		UserCode[] codes = challengeDBAdapter.queryOneData(user);
    
    		if (codes == null) {
    			text6.setVisibility(8);
    			<span style="font-size:18px;"><strong>button1.setTag(position + "");</strong></span>
    
    			button1.setOnClickListener(new OnClickListener() {
    				@Override
    				public void onClick(View v) {
    
    					<strong><span style="font-size:18px;">int temp = Integer.parseInt(v.getTag().toString()) ;</span></strong>
    // 设置验证码
    SetChallengeCodeThread codeThread = new SetChallengeCodeThread(temp);
    codeThread.start();
    
    				}
    			});
    		} else {
    			text6.setText(codes[0].getCode() + "");
    			button1.setVisibility(8);
    		}
    
    		return view;
    	}
    </span>




  • 相关阅读:
    深入理解计算机系统 第七章
    第七周 可执行程序的卸载
    Linux内核设计与实现 第三章
    第六周 进程的描述和进程的创建
    第五周 扒开系统调用的三层皮(下)
    UIWebView和Js交互
    CocoaPods的版本升级
    ios图片添加文字或者水印
    Objective-C 关联
    NSString进行urlencode编码
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/3988383.html
Copyright © 2011-2022 走看看