本文介绍了机器人的TextView值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些问题
我要改变我的TextView的价值。当我的code更改它会改变
I want to change my textview value. when my code change it will change
这里是code
public class SubMenuActivity extends Activity {
private static final int GALLERY = 0;
private static final int SUBMANU01 = 7;
private static final int MANU01 = 1;
private static final int MANU02 = 2;
private static final int MANU03 = 3;
private static final int MANU04 = 4;
private static final int MANU05 = 5;
TextView tx1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tx1 =(TextView)this.findViewById(R.id.textView1);
if(tx1.toString()=="1".toString())
{
tx1.setText("7");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
SubMenu fileMenu = menu.addSubMenu(GALLERY, SUBMANU01, Menu.NONE, "File");
fileMenu.add(GALLERY, MANU01, Menu.NONE, "new");
fileMenu.add(GALLERY, MANU02, Menu.NONE, "open");
fileMenu.add(GALLERY, MANU03, Menu.NONE, "save");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MANU01:
case MANU02:
case MANU03:
final String itemid = Integer.toString(item.getItemId());
tx1.setText(itemid);
return true;
}
return super.onOptionsItemSelected(item);
}
tx1.text值并未出现7,问题出在哪里?
我希望有人能告诉我这个问题。
tx1.text value did not show 7 ,where is the problem?I hope someone could tell me the problem.
推荐答案
比较喜欢这种
if(tx1.getText().toString().equals("1"))
{
tx1.setText("7");
}
这篇关于机器人的TextView值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!