0
如何動態重命名android文本視圖?我想根據編輯文本答案的名稱必須與已經創建的文本視圖相關來分配一個名稱。 例如,名稱a已在xml中分配了一個res id 示例 final TextView name a = (TextView)this.findViewById(R.id.Texti5);重命名android textview
editext.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode==KeyEvent.KEYCODE_ENTER) {
if("test1".equalsIgnoreCase(anstext.getText().toString())) {
// Here i want to give textview1 the 'name a'
}}
else
if("test2".equalsIgnoreCase(editext.getText().toString())) {
// Here i want to give textview1 the 'name b'
}
if("test5".equalsIgnoreCase(editext.getText().toString())) {
// Here i want to give textview1 the 'name c'
}
if("test7".equalsIgnoreCase(editext.getText().toString())) {
// Here i want to give textview1 the 'name d'
}
if (editext.getText().toString() != null){
testwrong.seText("wrong"); }
}
// here i want to see what name is given and give the name to textview1 so i can
perform click on that textview as it is clickable
textview1.performClck();
return true;
} });