forum frandroid - android et tablette

Aller au contenu

  • Connectez-vous avec Facebook Connectez-vous avec Twitter Connexion avec Google Connexion
  • Créer un compte
Change

Compatibilité entre terminaux


  • Merci de vous connecter pour répondre
1 réponse à ce sujet

#1
Maxime Gens

Maxime Gens

    Newbie

  • Membre
  • 5 messages
  • Marque:samsung
  • Modèle:SCL i9003
Bonjour, :) je fais appel à vous car j'ai un problème qui me bloque depuis bientôt un mois...
Mon application n’exécute pas toujours le code en fonction du terminal (oui oui)

Par exemple sur mon Galaxy Scl l'application fonctionnement parfaitement bien
Sur le Galaxy Y la listView n’apparaît pas.
Sur le terminal la listView n’apparaît pas non plus

Voici mon code

public class TestsActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
	 super.onCreate(savedInstanceState);
	 setContentView(R.layout.videos);
	
	 ListView listVideo = null;
	 Context context = this;
	
	 listVideo = (ListView)findViewById(R.video.listViewVideo);
	 try{
	 HttpClient client = new DefaultHttpClient();
	 HttpUriRequest request = new HttpGet("https://gdata.youtube.com/feeds/api/videos?author=trbourgois&v=2&alt=jsonc");
	 HttpResponse response = client.execute(request);
	
	 String jsonString = (response.getEntity() == null) ? null : EntityUtils.toString(response.getEntity());
	 JSONObject json = new JSONObject(jsonString);
	 JSONArray jsonArray = json.getJSONObject("data").getJSONArray("items");
		
	 ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
	 HashMap<String, Object> map ;
	
	 for (int i = 0; i < jsonArray.length(); i++) {
		 JSONObject jsonObject = jsonArray.getJSONObject(i);
		
		 map = new HashMap<String, Object>();
		 map.put("titre", jsonObject.getString("title"));
		 map.put("id", jsonObject.getString("id"));
		 map.put("uploaded", jsonObject.getString("uploaded"));
		 map.put("url", "http://www.youtube.com/v/"+jsonObject.getString("id")+"?version=3");
		
		 listItem.add(map);
	 }
	
	 SimpleAdapter adapter = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.affichageitem,
			 new String[] {"img", "titre", "uploaded"}, new int[] {R.video.miniaturevideo, R.video.titre, R.video.date}); listVideo.setAdapter(adapter);
	
	 }catch (Exception e) {
e.printStackTrace();
}
	
	 listVideo.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> adapter, View view, int position,long id) {
}
	 });
}
}

Mon XML :
videos.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>

<ListView
android:id="@+video/listViewVideo"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

</LinearLayout></code>

affichageitems.xml


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>

<ImageView
android:id="@+video/miniaturevideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="10dp"
android:contentDescription="bouh"
/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="10dp"
android:layout_weight="1"
>

<TextView android:id="@+video/titre"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="16dp"
android:textStyle="bold"
/>

<TextView android:id="@+video/date"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

</LinearLayout>

</LinearLayout>

Merci de votre aide  :)

#2
chpil

chpil

    RdS Développement

  • Responsable de section
  • 731 messages
  • LieuRennes
  • Modèle:ZTE Blade - Nexus 7 - Minix X5
Et tu as des messages particuliers dans les logs ?
Tu peux nous faire des copies d'écran pour expliquer le problème ?




0 utilisateur(s) li(sen)t ce sujet

0 membre(s), 0 invité(s), 0 utilisateur(s) anonyme(s)