好的,所以我正在尝试创建我自己的应用程序,它接受您键入的文本,然后将其转换为我已编写的其他语言,如何在EditText中搜索第一个字母然后更改它,然后继续这样做用户输入多长时间?
我是编程的新手,所以如果它很简单,我很抱歉,我没有与数组有关吗?
public class MainMenu extends Activity {
Button PasswordSetup;
boolean ShowPasswordBTN = false;
EditText UserInput,UserOutput;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.mainmenu);
PasswordSetup = (Button) findViewById(R.id.SetUpPassword);
UserInput = (EditText) findViewById(R.id.UserInput);
//What the user types
UserOutput = (EditText) findViewById(R.id.UserOutput);
//What i whnt it toshow in after converting the text
SharedPreferences GetPasswordBTN = getSharedPreferences("#.#.#.#", Context.MODE_PRIVATE);
ShowPasswordBTN = GetPasswordBTN.getBoolean("PasswordPres",false);
if(ShowPasswordBTN==true){
PasswordSetup.setVisibility(View.GONE);
}
UserInput.getText();
//I want to do it here
PasswordSetup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent GoToPasswordSetup = new Intent(getApplicationContext(),PasswordSetup.class);
startActivity(GoToPasswordSetup);
finish();
}
});
}
}
这就是我将字母改为
A = CB = DC = ED = FE = GF = HG = IH = JI = KJ = LK = ML = NM = ON = PO = QP = RQ = SR = TS = UT = VU = WV = XW = YX = ZY = BZ = A
答案 0 :(得分:1)
您可以在“编辑”文本中添加文本观察程序。
“我如何在EditText中搜索第一个字母然后更改它,然后继续这样做用户输入多长时间?”
myEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//check the sequence and do something
}
@Override
public void afterTextChanged(Editable arg0) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
});