我的应用程序中的Int,EditText操作和TabHost错误

时间:2014-08-24 18:23:02

标签: android android-edittext android-tabhost

我在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);

我有希望,有人会帮助我。

1 个答案:

答案 0 :(得分:1)

考虑到Wiek是你的EditText对象:

  1. Tmax = 220 - Integer.valueOf(Wiek.getText().toString());

  2. tabHost.setup();

  3. 说明:

    Wiek是一个对象,首先需要调用getText来获取在对象内输入的值。

    TabHost是类名,tabHost是您实例化的视图。