salut
mon application consiste a parser une fichier xml en ligne et qui contient des donnés pour hôtels(nom,adresse , catégorie)
j'ai importé les donnés dans un tableau aussi d'adapter ma listview avec les donnés de type checkable .mais quand j'ai essai de gérer les étoile de ratingbar pour définie la catégorie des hôtels 1 étoile ,2 étoile ... je ne réussie pas
d'abord regarder ma fichier xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 <hotels count="2">
<hotel>
<nom>el mouradi</nom>
<adr>hammamet</adr>
<categorie>5</categorie>
</hotel>
<hotel>
<nom>caralton</nom>
<adr>tunis</adr>
<categorie>4</categorie>
</hotel>
</hotels>
ma class main.java ou j'ai importé les donnés de fichier xml dans tableau ensuite afficher les donnés de type string en listview sans problème
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
package com.hotel.tn;
 
import java.util.ArrayList;
import java.util.HashMap;
 
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
 
import com.pxr.tutorial.xmltest.R;
 
 
 
 
 
import android.app.ListActivity;
import android.os.Bundle;
//import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
//import android.widget.RatingBar;
import android.widget.SimpleAdapter;
import android.widget.Toast;
 
public class Main extends ListActivity {
	 private ListView list;
    /** Called when the activity is first created. 
     * @param stars */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
        list = getListView();
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
 
 
        String xml = XMLfunctions.getXML();
        Document doc = XMLfunctions.XMLfromString(xml);
 
        int numResults = XMLfunctions.numResults(doc);
 
        if((numResults <= 0)){
        	Toast.makeText(Main.this, "pas de resultas", Toast.LENGTH_LONG).show();  
        	finish();
        }
 
		NodeList nodes = doc.getElementsByTagName("hotel");			
		for (int i = 0; i < nodes.getLength(); i++) {							
			HashMap<String, String> map = new HashMap<String, String>();	
 
			Element e = (Element)nodes.item(i);
			map.put("cat", XMLfunctions.getValue(e, "categorie"));
        	map.put("nom",XMLfunctions.getValue(e, "nom"));
        	map.put("adr",XMLfunctions.getValue(e, "adr"));
 
        	mylist.add(map);			
		}		
 
 
		ListAdapter adapter = new SimpleAdapter(this,mylist,R.layout.main, 
                      new  String[]{"nom","adr","cat"}, 
                       new int[] { R.id.item_title, R.id.item_subtitle,R.id.item_su});
 
 
      list.setAdapter(adapter);
       }}
ma class Listeadapter.java
eclipse m'affiche l'erreur suivante "the methode get int in the type Liste not applicable for the argemment string " au niveau ce ligne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
 rating.setRating(List.get("cat");
meme quand j'ai essaie a remplace List.get("cat") par un entier j'ai réussie
a exécuter mon application mai aucune changement pour le ratingbar au niveau des étoiles
aidez moi svp dde trouver une solution et merci

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
package com.hotel.tn;
 
//import android.app.ListActivity;
import java.util.List;
import java.util.Map;
 
import com.pxr.tutorial.xmltest.R;
 
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.SimpleAdapter;
 
public class Listeadapter extends SimpleAdapter  {
 
	private LayoutInflater	mInflater;
	public Listeadapter (Context context, List<? extends Map<String, ?>> data,
			int resource, String[] from, int[] to)
	{
		super (context, data, resource, from, to);
		mInflater = LayoutInflater.from (context);
	}
		public Object getItem (int position)
		{
			return getItem (position);
		}
 
		@Override
		public View getView (int position, View convertView, ViewGroup parent){
 
			if (convertView == null){
				// holder = new ViewHolder(); 
 
 
				convertView = mInflater.inflate (R.layout.main, null);
 
				// holder.
				RatingBar rating = (RatingBar)convertView.findViewById(R.id.rating);
 
				rating.setRating(List.get(cat));/*ou rating.setRating(2); ne fonctionne pas **/
				rating.setTag (position);
 
				// convertView.setTag(holder); 
 
			}
			return super.getView (position, convertView, parent);
		} }