SAISON 2 : EPISODE [2, 10] Application AndroGoree

Posted By: amenedem On samedi 14 mai 2011

Hello les Gars suite a une longue absence pour des raisons d’indisponibilités des acteurs ;-)  nous voici de retour avec les épisodes 2 à 10 .(Suite et Fin  Saison ) Enjoy .

Bon vous êtes surement au courant du challenge et je pense que tout le monde cherche tant bien que mal de la documentation ou des vrais code . dans cette saison , après avoir vu dans les saisons précédentes l'architecture d'un projet nous allons faire ensemble un vrai projet (Bref Mini Projet ;-) qui va parler des points suivants :

  • Les Activity
  • Les layout
  • Les Tab Layout les tab Activity
  • La Géolocalisation

Projet : AnDroGoree

Description : Affiche les Horaires de la chaloupe de Gorée et des informations utiles sur l’île

Les écrans qu'on doit avoir à la fin du Projet :
Ecran 1 affiche les Horaires départ Dakar
Ecran 2 Les points touristiques sur l’île 

Ok assez de bla bla à présent demarrer Eclipse et Créer votre Projet  préciser min SDK Api level (4) . 

I - Créer des Onglets ( TabActivity ) 
Dans votre Fichier GoreeHoraire.java qui est notre main activity va contenir 3 autres classes qui seront appelés lors de clique sur les 3 onglets (Départ sur Dakar , Départ sur L’île , Map )  .



      • Créer votre layout qui va se composer des Onglets : /res/layout/tab_horraire.xml 



<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>




      • Allons dans le main  GoreeHoraire.Java 
Dans votre "Principal Activity" ajouter ce code .(Bon essayons de comprendre le code ;-) )  
 @Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.tab_horraire );
   Resources res = getResources();
   TabHost tabHost = getTabHost();   
   TabHost.TabSpec spec;             
   Intent intent;                    
   intent = new Intent().setClass(this, HorraireDakar.class);
   spec = tabHost.newTabSpec("One").setIndicator("Depart Dakar ").setContent(intent);
   tabHost.addTab(spec);
   intent = new Intent().setClass(this, HorraireGoree.class);
   spec = tabHost.newTabSpec("two").setIndicator("Depart Goree").setContent(intent);
   tabHost.addTab(spec);
   intent = new Intent().setClass(this, PointChaudGoree.class);
   spec = tabHost.newTabSpec("three").setIndicator("",res.getDrawable(R.drawable.googlemapsicon)).setContent(intent);
   tabHost.addTab(spec);
   tabHost.setCurrentTab(0);
    }
       
Dans cette méthode " onCreate "  il y'a les classes Java  : HorraireDakar , HorraireGoree , PointChaudGoree . 
Expliquons un peu ce qui se passe a ce niveau : On a créer une nouvelle Intent qui implémente la classe appelée "  intent = new Intent().setClass(this, HorraireGoree.class);"


      • Créer la Classe Java HorraireDakar , HorraireGoree et PointChaudGoree 
Les fichiers layout correspondants :

    • HoraireDakar ==> res/layout/listhorrairedakar.xml 


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/homewidget"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
  <ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:fastScrollEnabled="true"
android:layout_height="wrap_content" />
 </RelativeLayout>
    • HorraireGoree ==>res/layout/listhorrairegoree.xml 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout

android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
  <ListView android:id="@+id/ListView011"
android:layout_width="wrap_content"
android:fastScrollEnabled="true"
android:layout_height="wrap_content" 
/>
</RelativeLayout> 
    • PointChaudGoree ==>res/layout.viewmap.xml 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:id="@+id/mainlayout"
    android:layout_height="fill_parent">
    <TextView
android:id="@+id/myLocationText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:id="@+id/mapview"
android:apiKey="@string/app_key"
  />
  <ZoomControls android:id="@+id/zoomcontrols"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"/>
</RelativeLayout>




      • Les codes Java 
    • HorraireDakar.java 
public class HorraireDakar extends Activity{
private ListView lv1; 
private String lv_name[]={"06 h 15","07 h 30","10 h 00","11 h 00","12 h 30","14 h 30","16 h 00","17 h 00 (sauf Samedi) ","18 h 30","20 h 00","22 h 30","23 h 30 (vendredi uniquement)","00 h 45 (samedi uniquement)"};
 
@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//Le layout implementé
        setContentView(R.layout.listhorrairedakar);
//Recherche de l'object identifier by id
        lv1=(ListView)findViewById(R.id.ListView01);
// On cree un adaptateur de la liste
        lv1.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, lv_name));
    }
}
    • HorraireGoree.java (Faire de même) tout juste voire si vous avez compris le principe ;-)
    • PointChaudGoree.java (La partie de geolocalisation ) 
Dans cette partie on veux faire ressortir sur une carte map(G-map) les points chaud ou touristique sur Gorée, les restaurants etc ... si vous le permettez on le detail un peu plus loin dans nos  prochains épisodes ......  

Meetup GTUG Dakar à l'ESMT

Posted By: Hassane Moustapha On mardi 3 mai 2011

Bonjour GTUG,

Samedi le 23 Avril 2011, GTUG Dakar avait tenu son meetup mensuel. Mais celui-ci était "spécial" car il a été dédié à Android et au lancement de la compétition "Android Challenge ".

Pendant ce meetup, Hovi le spécialiste Android du groupe avait gentillement fait un long exposé sur Android. Parcourant l'architecture et les bases de Android, il a encore, une fois de plus, réussi à intéresser les 70 personnes présentes à son petit robot vert :)

On n'oublie pas de remercier nos amis du club scientifique de l'ESMT qui ont accepté d'organiser cette rencontre dans les locaux de leur établissement.

Pour ne pas être long, je vous laisse découvrir ....



snipt

Fourni par Blogger.