如何动态重命名android文本视图?我想根据给定的编辑文本答案分配一个名称,该名称必须与已创建的文本视图相关。例如名称 a 已经在 xml 示例中分配了一个 res id 最终 TextView 名称 a = (TextView) this.findViewById(R.id.Texti5);
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;
} });