1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
package com.example.kro.easydati;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.example.kro.easydati.config.Appareil;
import java.util.List;
/**
* Created by KRO on 04/12/2014.
*/
public class CustomAdapterAppareil extends BaseAdapter {
Context contexte;
//LayoutInflater mInflater;
// String[] Title, Detail;
//
int Bt1,Bt2;
List<Appareil> Numero;
public CustomAdapterAppareil(Context contexte, List<Appareil> numero, int bt1, int bt2) {
this.contexte = contexte;
Numero = numero;
Bt1 = bt1;
Bt2 = bt2;
}
public CustomAdapterAppareil() {
super();
}
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
LayoutInflater mInflater = (LayoutInflater) contexte.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(convertView == null) {
convertView = mInflater.inflate(R.layout.custom_appareil, parent, false);
holder = new ViewHolder();
holder.mNumero = (TextView)convertView.findViewById(R.id.numero);
holder.mBt1 = (Button)convertView.findViewById(R.id.button1);
holder.mBt2 = (Button)convertView.findViewById(R.id.button2);
//holder.mNumero.setText(Numero[position]);
holder.mNumero.setText(Numero.get(position).toString());
convertView.setTag(holder);
holder.mBt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//Here I need to get that position
// int position=(Integer)arg0.getTag();
// String currentPos = arg0.getTag().toString();
// Toast.makeText(contexte, "position : " + currentPos , Toast.LENGTH_LONG).show();
//Toast.makeText(contexte, Title[position], Toast.LENGTH_LONG).show();
}
});
holder.mBt2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//Here I need to get that position
// int position=(Integer)arg0.getTag();
// String currentPos = arg0.getTag().toString();
// Toast.makeText(contexte, "position : " + currentPos , Toast.LENGTH_LONG).show();
// Toast.makeText(contexte, Title[position], Toast.LENGTH_LONG).show();
}
});
}
else
{
holder = (ViewHolder)convertView.getTag();
}
return convertView;
}
static class ViewHolder {
TextView mNumero;
Button mBt1;
Button mBt2;
}
} |
Partager