我在Adroid Studio中制作我的第一个简单应用程序时遇到困难
1)
Error38, 20) error: bad operand types for binary operator '-'
first type: int
second type: EditText
//从用户
获取数字EditText = Age;
Age = (EditText) findViewById(R.id.inAge);
//接下来,Tmax必须为220 - 用户输入数
Tmax = 220 - Age;
这是带有数字的错误 - 来自用户输入的数字。
2)。
Error47, 16) error: non-static method setup() cannot be referenced from a static context
我不知道为什么它不能正常工作。
TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
TabHost.setup(); *//Why is error here?*
TabHost.TabSpec tabSpec = tabHost.newTabSpec("Calc");
tabSpec.setContent(R.id.Calc);
tabSpec.setIndicator("Calc");
tabHost.addTab(tabSpec);
tabSpec = tabHost.newTabSpec("Hints"); *//second table, witchout [TabHost.TabSpac] ??*
tabSpec.setContent(R.id.Hints);
tabSpec.setIndicator("Hints");
tabHost.addTab(tabSpec);
我有希望,有人会帮助我。
答案 0 :(得分:1)
考虑到Wiek是你的EditText
对象:
Tmax = 220 - Integer.valueOf(Wiek.getText().toString());
tabHost.setup();
说明:
Wiek是一个对象,首先需要调用getText来获取在对象内输入的值。
TabHost
是类名,tabHost
是您实例化的视图。