I wanted to make a small application when client types their password
it has acceded list but the problem I find when I run list and
password at the same time
here is the code for two classes
Code: one class

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        password= (EditText)findViewById(R.id.password);
        ok= (Button)findViewById(R.id.ok);

        ok.setOnClickListener(this);
        password.setOnClickListener(this);

        final String TESTSTRING = new String("1234");

                FileOutputStream fOut;
                try {
                        fOut = openFileOutput("fichier.txt",
                                                                
MODE_WORLD_READABLE);

                OutputStreamWriter osw = new OutputStreamWriter(fOut);


                osw.write(TESTSTRING);


                osw.flush();
                osw.close();
                } catch (FileNotFoundException e) {

                        e.printStackTrace();
                }

                catch (IOException e) {

                        e.printStackTrace();
                }



    }


        public void sendFeedback(View button) {


             String name1 =password.getText().toString();

             try {
             FileInputStream fIn = openFileInput("fichier.txt");
                        InputStreamReader isr = new InputStreamReader(fIn);

                        char[] inputBuffer = new char[name1.length()];


                                isr.read(inputBuffer);


                                String readString = new String(inputBuffer);


                        if (readString.equals(name1)){
                                 Toast.makeText(this,"Mot de passe
correct",Toast.LENGTH_SHORT).show();
                             Tutoriel5_Android aa=new Tutoriel5_Android();
                             aa.showDialog(BIND_AUTO_CREATE);
                        } else{
                             Toast.makeText(this,"Mot de passe
Incorrect",Toast.LENGTH_SHORT).show();


                    }
                        } catch (IOException e) {
                             Toast.makeText(this,"Une erreur est
survenue",Toast.LENGTH_SHORT).show();

                                e.printStackTrace();
                        }
}


        @Override
        public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
                // TODO Auto-generated method stub
                return false;
        }

code two class List

public class Tutoriel5_Android extends Activity {

        private ListView maListViewPerso;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Récupération de la listview créée dans le fichier main.xml
        maListViewPerso = (ListView) findViewById(R.id.listviewperso);

        //Création de la ArrayList qui nous permettra de remplire la
listView
        ArrayList<HashMap<String, String>> listItem = new
ArrayList<HashMap<String, String>>();

        //On déclare la HashMap qui contiendra les informations pour
un item
        HashMap<String, String> map;

        //Création d'une HashMap pour insérer les informations du
premier item de notre listView
        map = new HashMap<String, String>();
        //on insère un élément titre que l'on récupérera dans le
textView titre créé dans le fichier affichageitem.xml
        map.put("titre", "compte");
        //on insère un élément description que l'on récupérera dans le
textView description créé dans le fichier affichageitem.xml
        map.put("description", "opération de compte");
        //on insère la référence à l'image (convertit en String car
normalement c'est un int) que l'on récupérera dans l'imageView créé
dans le fichier affichageitem.xml

        //enfin on ajoute cette hashMap dans la arrayList
        listItem.add(map);

        //On refait la manip plusieurs fois avec des données
différentes pour former les items de notre ListView

        map = new HashMap<String, String>();
        map.put("titre", "opération financière");
        map.put("description", "trasfert de solde");

        listItem.add(map);

        map = new HashMap<String, String>();
        map.put("titre", "Suvie");
        map.put("description", "partie wap");

        listItem.add(map);



        //Création d'un SimpleAdapter qui se chargera de mettre les
items présent dans notre list (listItem) dans la vue affichageitem
        SimpleAdapter mSchedule = new SimpleAdapter
(this.getBaseContext(), listItem, R.layout.affichageitem,
               new String[] {"img", "titre", "description"}, new int[]
{R.id.img, R.id.titre, R.id.description});

        //On attribut à notre listView l'adapter que l'on vient de
créer
        maListViewPerso.setAdapter(mSchedule);

        //Enfin on met un écouteur d'évènement sur notre listView
        maListViewPerso.setOnItemClickListener(new
OnItemClickListener() {
                        @Override
                @SuppressWarnings("unchecked")
                public void onItemClick(AdapterView<?> a, View v, int
position, long id) {
                                //on récupère la HashMap contenant les infos de 
notre item (titre,
description, img)
                        HashMap<String, String> map = (HashMap<String, String>)
maListViewPerso.getItemAtPosition(position);
                        //on créer une boite de dialogue
                        AlertDialog.Builder adb = new
AlertDialog.Builder(Tutoriel5_Android.this);
                        //on attribut un titre à notre boite de dialogue
                        adb.setTitle("Sélection Item");
                        //on insère un message à notre boite de dialogue, et 
ici on
affiche le titre de l'item cliqué
                        adb.setMessage("Votre choix : "+map.get("titre"));
                        //on indique que l'on veut le bouton ok à notre boite de
dialogue
                        adb.setPositiveButton("Ok", null);
                        //on affiche la boite de dialogue
                        adb.show();
                }
         });

    }
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to