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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
public class UserListAdapter extends BaseAdapter implements OnClickListener {
private static final String TAG = UserListAdapter.class.getName();
private Activity activity;
private Vector<Book> items;
private Context mContext;
ImageButton retour;
public UserListAdapter(Activity activity, Vector<Book> items) {
Log.i(TAG, TAG);
this.activity = activity;
this.items = items;
}
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = activity.getLayoutInflater();
convertView = inflater.inflate(R.layout.listrow_user, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.nameTV);
holder.headingLL = (LinearLayout) convertView
.findViewById(R.id.headingLL);
holder.headingTV = (TextView) convertView
.findViewById(R.id.headingTV);
holder.nameLL = (LinearLayout) convertView
.findViewById(R.id.nameLL);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (position < items.size()) {
final Book book = items.get(position);
if (book != null && (book.getProduits().length() == 1)) {
holder.nameLL.setVisibility(View.GONE);
holder.headingLL.setVisibility(View.VISIBLE);
holder.headingTV.setText(book.getProduits());
holder.headingLL
.setBackgroundColor(android.R.color.transparent);
} else {
holder.nameLL.setVisibility(View.VISIBLE);
holder.headingLL.setVisibility(View.GONE);
holder.name.setText(book.getProduits());
View ll = (LinearLayout) holder.name.getParent();
ll.setFocusable(true);
ll.setSelected(true);
ll.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
/* action sur le clic */
if (book.getListe().equals("A") ) {
Toast.makeText(activity.getApplicationContext(),
"produit liste A",
Toast.LENGTH_SHORT).show();
Intent menuIntent = new Intent(activity,MenuproduitsInterventionA.class);
menuIntent.putExtra("produits",book.getProduits().toString() );
activity.startActivity(menuIntent);
finish();
}
else if (book.getListe().equals("B")) {
Toast.makeText(activity.getApplicationContext(),
"produit liste B",
Toast.LENGTH_SHORT).show();
Intent menuIntent = new Intent(activity,MenuproduitsInterventionB.class);
activity. startActivityForResult(menuIntent, position);
finish();
} else if (book.getListe().equals("C")) {
Toast.makeText(activity.getApplicationContext(),
"Vous avez cliquez sur produit liste C",
Toast.LENGTH_SHORT).show();
Intent menuIntent = new Intent(activity,MenuproduitsInterventionC.class);
activity.startActivity(menuIntent);
finish();
}
}
private Context getApplication() {
// TODO Auto-generated method stub
return null;
}
private Context getBaseContext() {
// TODO Auto-generated method stub
return null;
}
private void startActivity(Intent menuIntent) {
// TODO Auto-generated method stub
}
});
}
}
return convertView;
}
protected void finish() {
// TODO Auto-generated method stub
}
private static class ViewHolder {
TextView name, headingTV;
LinearLayout nameLL, headingLL;
}
@Override
public int getCount() {
return items.size();
}
@Override
public Object getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
} |
Partager