IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Problème de récuperation d'un String depuis une classe


Sujet :

Android

  1. #1
    Membre du Club
    Homme Profil pro
    Administrateur Télécoms
    Inscrit en
    Décembre 2010
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Administrateur Télécoms
    Secteur : Service public

    Informations forums :
    Inscription : Décembre 2010
    Messages : 67
    Points : 52
    Points
    52
    Par défaut Problème de récuperation d'un String depuis une classe
    Bonjour a la communauté je fait ce post en n ayant pas trouve de réponse sur mon problème de variable voila mon problème. J ai trouvé un script mais j ai un petit problème j ai userlistadapter qui récupère les info d une class book cela me permet d afficher un listview quand je clic sur le nom du produit je sais ouvrir l activité en fonction du produit par contre ma fiche produit ne me retourne pas le nom dans le titre malgré le tag

    je vous met les deux class merci a vous pour vos idées car j ai du mal sur les string


    mon userlistadapter qui recupere mes produits de ma class book
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    	}
     
     
     
     
     
     
    }

    et mon activité qui dois recuperer mon nom dans le titre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    
    
    	TextView titre;
    	private static final String TAG =UserListAdapter.class.getName();
    	private Activity activity;
    	private Vector<Book> items;
    	private Context mContext;
    
    	
    	public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.menu_scenario_a);
    		
    		// gestion bouton dans la barre accueil include layout
    		LinearLayout monInclude = (LinearLayout) findViewById(R.id.include1);
    		retour=(ImageButton)monInclude.findViewById(R.id.imageButtonRetour);
    		retour.setOnClickListener(this);
    
    		
    
    		// gestion bouton dans le layout principal
    		bleve = (Button) findViewById(R.id.Boutonbleve);
    		bleve.setOnClickListener(this);// ecoute du bouton sur un clic
    		titre=(TextView)findViewById(R.id.textView1);
    		titre.setText(TAG); Ici le pb j affiche pas le nom du produit
    
    		uvce=(Button)findViewById(R.id.Boutonuvce);
    		uvce.setOnClickListener(this);
    		
    
    
    
    }
    voila j espère avoir été clair merci a vous je suis néophyte

  2. #2
    Expert éminent

    Avatar de Feanorin
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    4 589
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2004
    Messages : 4 589
    Points : 9 149
    Points
    9 149
    Par défaut
    Bonjour,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    private static final String TAG = UserListAdapter.class.getName();
    Voici la fonction que tu appelles :
    http://developer.android.com/referen...html#getName()

    Returns the name of the class represented by this Class. For a description of the format which is used, see the class definition of Class.

    Returns
    the name of the class represented by this Class.
    Soit TAG est égal à "UserListAdapter" dans ton cas, non ?

    Après essaye de faire quelque tutoriel que tu trouveras ici :
    Pour Java :
    http://java.developpez.com/cours/
    pour Android
    http://android.developpez.com/cours/...Debutant#Debut

    Essaye de comprendre leur fonctionnement, leur intérêt.
    Responsable Android de Developpez.com (Twitter et Facebook)
    Besoin d"un article/tutoriel/cours sur Android, consulter la page cours
    N'hésitez pas à consulter la FAQ Android et à poser vos questions sur les forums d'entraide mobile d'Android.

  3. #3
    Membre du Club
    Homme Profil pro
    Administrateur Télécoms
    Inscrit en
    Décembre 2010
    Messages
    67
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Administrateur Télécoms
    Secteur : Service public

    Informations forums :
    Inscription : Décembre 2010
    Messages : 67
    Points : 52
    Points
    52
    Par défaut
    Merci pour toutes ces infos je regarde

Discussions similaires

  1. Problème d'accès au matériel embarqué depuis une application web
    Par j_esti dans le forum Développement Web en Java
    Réponses: 0
    Dernier message: 16/06/2014, 23h15
  2. Problème accès Textbox depuis une classe enfant
    Par Moutmouth dans le forum C#
    Réponses: 1
    Dernier message: 31/01/2011, 12h34
  3. [1.x] Problèmes avec l'envoi d'email depuis une task
    Par nsoinard dans le forum Symfony
    Réponses: 2
    Dernier message: 21/04/2010, 14h57
  4. Réponses: 4
    Dernier message: 14/10/2009, 10h52
  5. [MySQL] Problème de récuperation de l'ID d'une image
    Par Arkoze dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 30/01/2008, 21h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo