嗯..也许是一个有点愚蠢的问题,但我自己不明白......
package com.example.wettkampftimerbt;
import android.content.Intent;
import android.inputmethodservice.Keyboard.Key;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class ServMPW extends Activity_ActivityGroup implements OnClickListener{
Button enter, cancel;
EditText eingabe, eingabe2, masterpw;
String pwx, eingabex, pass, adminacchint1x, adminacchint2x;
private final String PREFS_NAME = "prefs";
private final String PREFS_PW = "pw";
private final String PREFS_lang = "lang";
private final String TITLE5 = "title5";
private final String ADMINACCHINT1 = "adminacchint1";
private final String ADMINACCHINT2 = "adminacchint2";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.servmpw);
//((TextView)((FrameLayout)((LinearLayout)((ViewGroup) getWindow().getDecorView()).getChildAt(0)).getChildAt(0)).getChildAt(0)).setGravity(Gravity.CENTER);
String title5x=(getSharedPreferences(PREFS_lang, MODE_PRIVATE).getString(TITLE5, "Administrationszugang"));
this.setTitle(title5x);
adminacchint1x=(getSharedPreferences(PREFS_lang, MODE_PRIVATE).getString(ADMINACCHINT1, "Passwort"));
adminacchint2x=(getSharedPreferences(PREFS_lang, MODE_PRIVATE).getString(ADMINACCHINT2, "falsches Passwort"));
enter=(Button)findViewById(R.id.enter);
cancel=(Button)findViewById(R.id.cancel);
eingabe=(EditText)findViewById(R.id.eingabe);
masterpw=(EditText)findViewById(R.id.masterpw);
eingabe.setHint(adminacchint1x);
eingabe2=(EditText)findViewById(R.id.eingabe2);
enter.setOnClickListener(this);
cancel.setOnClickListener(this);
}
public void onClick (View v){
if (v==cancel){
finish();}
else if (v == enter){
entermeth();
}
else {
eingabe.setText("");
eingabe.setHint(adminacchint2x);}}
public void OnKey (View v, int keyCode, KeyEvent event)
{
if (keyCode==66)
entermeth();
}
public void entermeth(){
eingabe2.setText(getSharedPreferences(PREFS_NAME, MODE_PRIVATE).getString(PREFS_PW, "bbb"));
pwx = eingabe2.getText().toString();
Log.e("pw", PREFS_PW + "." + pwx);
eingabex = eingabe.getText().toString();
masterpw.setText("aaa");
String masterpwx = masterpw.getText().toString();
Log.e("pw:", masterpwx);
if (eingabex.equals(pwx)||(eingabex.equals(masterpwx))){
Intent admin = new Intent (ServMPW.this, Admin.class);
ServMPW.this.finish();
startActivity(admin);}
}
}
如果按下软键盘上的回车按钮,我想点击我自己的回车按钮。但它不起作用......我错过了什么?