problem for password

Put your problem here if it does not fit any of the other categories.

problem for password

Postby jaafar » Sun Mar 20, 2011 2:00 pm

I'm having difficulty when I click ok nothing happens AC
Code: Select all
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. */
   
    EditText editText;
    Button ok;
   
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        editText= (EditText)findViewById(R.id.editText);
        ok= (Button)findViewById(R.id.ok);
       
       /* ok.setOnClickListener(this);*/
        editText.setOnClickListener(this);
         
    }
   /*final EditText nameField = (EditText) findViewById(R.id.editText);  */
    

   public void sendFeedback(View button) { 
       String name="1234";
      
        String name1 ="chaine";
         //nameField.getText().toString(); 
      
      
       if(name.equals(name1))
         Toast.makeText(this,"Mot de passe orrect",Toast.LENGTH_SHORT).show();
         else
        Toast.makeText(this,"Mot de passe Incorrect",Toast.LENGTH_SHORT).show();
        
          // Do click handling here 
       }


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


   @Override
   public void onClick(View v) {
      // TODO Auto-generated method stub
      
   }


}
jaafar
Freshman
Freshman
 
Posts: 7
Joined: Sat Mar 12, 2011 2:45 pm

Top

Re: problem for password

Postby emesaeler » Mon Mar 28, 2011 8:57 pm

You have /*Commented*/ out your ok.setOnClickListener(), that is why nothing happens when you click OK. Also, not sure why you have a click listener on your editText. If anything, you should use onKeyListener, assuming you wanted to register an "Enter" key. Couple other strange things you have Commented-out as well.

This should have what you need:
http://developer.android.com/resources/ ... stuff.html
emesaeler
Freshman
Freshman
 
Posts: 3
Joined: Thu Mar 24, 2011 3:59 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests