android listview imageview点击事件,android listview的item里面的imageview的点击事件

package com.example.adapter;

import java.io.File;

import java.net.URI;

import java.util.List;

import com.yuayang.lc.R;

import com.yuyang.entity.light;

import android.content.Context;

import android.util.Log;

import android.view.LayoutInflater;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.ViewGroup;

import android.widget.BaseAdapter;

import android.widget.ImageView;

import android.widget.TextView;

public class loadadapter  extends BaseAdapter {

private Context context;

private List list;

private int Viewitem;

private LayoutInflater linInflater;

private ImageView iv;

private ImageView iv1;

public loadadapter(Context context, int Viewitem,List list){

this.context=context;

this.list=list;

this.Viewitem=Viewitem;

}

@Override

public int getCount() {

return list.size();

}

@Override

public Object getItem(int position) {

return list.get(position);

}

@Override

public long getItemId(int position) {

return position;

}

@Override

public View getView(final int position, View convertView, ViewGroup parent) {

Log.i("index", ".......1");

TextView tv;

linInflater=(LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);

convertView=linInflater.inflate(Viewitem, null);

iv=(ImageView) convertView.findViewById(R.id.norlight_iv2);

iv1=(ImageView) convertView.findViewById(R.id.norlight_iv1);

tv=(TextView) convertView.findViewById(R.id.norlight_tv1);

if(list.get(position).getStatus()==0){

iv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_17));

iv1.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_o6));

}else{

iv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_10));

iv1.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_06_1));

}

iv.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

Log.i("index", ""+iv);

if(list.get(position).getStatus()==0){

iv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_10));

iv1.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_06_1));

list.get(position).setStatus(1);

notifyDataSetChanged();

}else if(list.get(position).getStatus()==1) {

iv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_17));

iv1.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.p1_jd_ptd_o6));

list.get(position).setStatus(0);

notifyDataSetChanged();

}

return ;

}

});

tv.setText(list.get(position).getLightName());

return convertView;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值