hello I have a problem in my code when I type the password and I click
enter it shows me an exception message
1 class main for password
    package com.tutomobile.android.listView;




    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;

    import android.app.Activity;

    import android.os.Bundle;

    import android.view.KeyEvent;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.View.OnKeyListener;

    import android.widget.Button;
    import android.widget.EditText;


    import android.widget.Toast;



    public class main extends Activity implements OnClickListener,
OnKeyListener {
        /** Called when the activity is first created. */
       /*Display display=null;*/
        EditText password;
        Button ok;


        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");

          // ##### Write a file to the disk #####
          /* We have to use the openFileOutput()-method
           * the ActivityContext provides, to
           * protect your file from others and
           * This is done for security-reasons.
           * We chose MODE_WORLD_READABLE, because
           *  we have nothing to hide in our file */
          FileOutputStream fOut;
          try {
             fOut = openFileOutput("fichier.txt",
                            MODE_WORLD_READABLE);

          OutputStreamWriter osw = new OutputStreamWriter(fOut);

          // Write the string to the file
          osw.write(TESTSTRING);
          /* ensure that everything is
           * really written out and close */
          osw.flush();
          osw.close();
          } catch (FileNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }
          // ##### Read the file back in #####
          catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }



        }
       /*final EditText nameField = (EditText)
findViewById(R.id.editText);  */


       public void sendFeedback(View button) {


            String name1 =password.getText().toString();
           /* System.out.print("name1="+name1);*/
             //nameField.getText().toString();
            try {
            FileInputStream fIn = openFileInput("fichier.txt");
             InputStreamReader isr = new InputStreamReader(fIn);
             /* Prepare a char-Array that will
              * hold the chars we read back in. */
             char[] inputBuffer = new char[name1.length()];
             // Fill the Buffer with data from the file

                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();

                 // Do click handling here
              }
             } 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;
       }


       @Override

          public void onClick(View v) {
                sendFeedback(ok);
        }
    }

    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();
               }
             });

        }
    }

erreur logcat
    03-30 13:55:06.493: ERROR/AndroidRuntime(257): Uncaught handler:
thread main exiting due to uncaught exception
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):
java.lang.IllegalArgumentException: Activity#onCreateDialog did not
create a dialog for id 1
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.app.Activity.createDialog(Activity.java:869)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.app.Activity.showDialog(Activity.java:2408)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.tutomobile.android.listView.Principal.sendFeedback(Principal.java:
94)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.tutomobile.android.listView.Principal.onClick(Principal.java:118)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.View.performClick(View.java:2344)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.View.onTouchEvent(View.java:4133)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.widget.TextView.onTouchEvent(TextView.java:6510)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.View.dispatchTouchEvent(View.java:3672)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:
1202)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.app.Activity.dispatchTouchEvent(Activity.java:1987)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1658)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.os.Handler.dispatchMessage(Handler.java:99)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.os.Looper.loop(Looper.java:123)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
java.lang.reflect.Method.invokeNative(Native Method)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
java.lang.reflect.Method.invoke(Method.java:521)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:791)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
    03-30 13:55:06.513: ERROR/AndroidRuntime(257):     at
dalvik.system.NativeStart.main(Native Method)
    03-30 13:55:06.523: ERROR/dalvikvm(257): Unable to open stack
trace file '/data/anr/traces.txt': Permission denied

-- 
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