| 12
 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
 
 | 
package com.lolea.first;
import java.util.Vector;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
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.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.lolea.index.table.to.Book;
public class UserListAdapter extends BaseAdapter {
	private static final String TAG = UserListAdapter.class.getName();
	private Activity activity;
	private Vector<Book> items;
//	private Context mContext;
	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() == "A") {
							;
							Intent menuIntent = new Intent(activity, MenuproduitsAB.class);
				startActivity(menuIntent)  ici le code pour demarrer mon activity mais rien ne se passe
							finish();
							
							
						}
						else if (book.getListe() == "B") {
							Intent menuIntent = new Intent(activity
									.getApplicationContext(),
									MainActivity.class);
							Toast.makeText(activity.getApplicationContext(),Ici  le toast qui fonctionne bien
									"Vous avez cliquez sur produit liste B",
									Toast.LENGTH_SHORT).show();
							startActivity(menuIntent);
							finish();
						} else if (book.getListe() == "C") {
							Intent menuIntent = new Intent(activity
									.getApplicationContext(),
									MainActivity.class);
							startActivity(menuIntent);
							finish();
							Toast.makeText(activity.getApplicationContext(),
									"Vous avez cliquez sur produit liste C",
									Toast.LENGTH_SHORT).show();
						}
					}
					private Context getBaseContext() {
						// TODO Auto-generated method stub
						return null;
					}
					private void startActivity(Intent menuIntent) {
						// TODO Auto-generated method stub
					}
				});
			}
		}
		return convertView;
	}
	protected Context getApplicationContext() {
		// TODO Auto-generated method stub
		return null;
	}
	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;
	}
} | 
Partager