我是学习Android的新手,我有很多错误,但不知道如何解决这个错误 [英] I Am New In Larning Android I Have To Many Error But Cant Have Idea How To Resolve Thise Error
问题描述
package com.example.test1;
import android.app.Activity;
import android.os.Bundle;
导入android.view.View;
导入android.view.View.OnClickListener;
导入android.widget.Button;
公共类MainActivity扩展Activity实现OnClickListner
{
Textview dollor;
Textview euro;
RedioButton dte;
RedioButton etd;
按钮计算;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout .activity_main);
dollor =(textview)this.findViewById(R.id.dollor);
euro =(textview)this .findViewById(R.id.euro);
dte =(RedioButton)this.findViewById(R.id.dte);
etd =(RedioButton)this.findViewById(R.id.etd);
计算=(按钮)this.fi ndViewById(R.id.calculate);
calculate.setOnClickListener(this);
}
public void onClick(查看v)
{
if(dte.isCheked())
{
convertDollorToEuro( );
}
if(etd.isCheked())
{
convertDollorToEuro();
}
protected void convertDollorToEuro()
{
double val = Double.parseDouble(Dollor.getText.toString());
euro.setText(Double.toString(val * 0.60));
< br $>
}
protected void convertDollorToEuro()
{
double val = Double .parseDouble(euro.getText.toString());
Dollor.setText(Double.toString(val * 0.60));
}
}
}
GETING ERROR
描述资源路径位置类型
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第27行Java问题
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第26行Java问题
类型View中的方法setOnClickListener(View.OnClickListener)不适用于参数(MainActivity)MainActivity.java / test1 / src / com / example / test1第30行Java问题
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第27行Java问题
Textview无法解析为类型MainActivity .java / test1 / src / com / example / test1第24行Java问题
textview无法解析为类型MainActivity.java / test1 / src / com / example / test1第23行Java问题
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第26行Java问题
textview无法解析为类型MainActivity.java / test1 / SRC / COM /示例/ TEST1利ne 24 Java问题
语法错误,插入enum Identifier来完成EnumHeaderName MainActivity.java / test1 / src / com / example / test1 line 45 Java问题
语法错误on tokenvoid,@ expected MainActivity.java / test1 / src / com / example / test1 line 45 Java问题
令牌上的语法错误void,@ expected MainActivity.java / test1 / src / com / example / test1第52行Java问题
语法错误,插入EnumBody来完成BlockStatement MainActivity.java / test1 / src / com / example / test1第45行Java问题
方法convertDollorToEuro()未定义类型MainActivity MainActivity.java / test1 / src / com / example / test1 line 37 Java问题
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第35行Java问题
方法convertDollorToEuro()未定义类型MainActivity MainActivity.java / test1 / src / com / example / test1 line 41 Java问题
RedioButton不能是res类型为MainActivity.java / test1 / src / com / example / test1第39行Java问题
[I18N]硬编码字符串Dollor to Euro,应使用@string资源activity_main.xml / test1 / res / layout line 42 Android Lint问题
[I18N]硬编码字符串Euro to Dollor,应使用@string资源activity_main.xml / test1 / res / layout line 47 Android Lint问题
[I18N]硬编码字符串Calculate,应使用@string资源activity_main.xml / test1 / res / layout line 53 Android Lint问题
[I18N]硬编码字符串DOLLOR,应该使用@string资源activity_main.xml / test1 / res / layout line 18 Android Lint问题
此文本字段未指定inputType或提示activity_main.xml / test1 / res / layout line 20 Android Lint问题
[I18N]硬编码字符串EURO,应该使用@string资源activity_main.xml / test1 / res / layout line 30 Android Lint问题
这个文本字段确实不指定inputType或提示activity_m ain.xml / test1 / res / layout line 33 Android Lint问题
Textview无法解析为类型MainActivity.java / test1 / src / com / example / test1第13行Java问题
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第14行Java问题
RedioButton无法解析为类型MainActivity.java / test1 / src / com / example / test1第15行Java问题
不推荐使用AbsoluteLayout activity_main.xml / test1 / res / layout line 2 Android Lint问题
Textview无法解析为某种类型MainActivity.java / test1 / src / com / example / test1第23行Java问题
OnClickListner无法解析为类型MainActivity.java / test1 / src / com / example / test1第10行Java问题
Textview无法解析为类型MainActivity.java / test1 / src / com / example / test1第12行Java问题
语法错误,插入enum Identifier以完成EnumHeaderName MainActivity.java / TEST1 / SRC / COM /示例/ TEST1林e 52 $ Java问题
语法错误,插入EnumBody来完成BlockStatement MainActivity.java / test1 / src / com / example / test1 line 52 Java问题
package com.example.test1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListner
{
Textview dollor;
Textview euro;
RedioButton dte;
RedioButton etd;
Button calculate;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dollor=(textview)this.findViewById(R.id.dollor);
euro=(textview)this.findViewById(R.id.euro);
dte=(RedioButton)this.findViewById(R.id.dte);
etd=(RedioButton)this.findViewById(R.id.etd);
calculate=(Button)this.findViewById(R.id.calculate);
calculate.setOnClickListener(this);
}
public void onClick(View v)
{
if(dte.isCheked())
{
convertDollorToEuro();
}
if(etd.isCheked())
{
convertDollorToEuro();
}
protected void convertDollorToEuro()
{
double val= Double.parseDouble(Dollor.getText.toString());
euro.setText(Double.toString(val*0.60));
}
protected void convertDollorToEuro()
{
double val= Double.parseDouble(euro.getText.toString());
Dollor.setText(Double.toString(val*0.60));
}
}
}
GETING ERROR
Description Resource Path Location Type
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 27 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 26 Java Problem
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (MainActivity) MainActivity.java /test1/src/com/example/test1 line 30 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 27 Java Problem
Textview cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 24 Java Problem
textview cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 23 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 26 Java Problem
textview cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 24 Java Problem
Syntax error, insert "enum Identifier" to complete EnumHeaderName MainActivity.java /test1/src/com/example/test1 line 45 Java Problem
Syntax error on token "void", @ expected MainActivity.java /test1/src/com/example/test1 line 45 Java Problem
Syntax error on token "void", @ expected MainActivity.java /test1/src/com/example/test1 line 52 Java Problem
Syntax error, insert "EnumBody" to complete BlockStatement MainActivity.java /test1/src/com/example/test1 line 45 Java Problem
The method convertDollorToEuro() is undefined for the type MainActivity MainActivity.java /test1/src/com/example/test1 line 37 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 35 Java Problem
The method convertDollorToEuro() is undefined for the type MainActivity MainActivity.java /test1/src/com/example/test1 line 41 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 39 Java Problem
[I18N] Hardcoded string "Dollor to Euro", should use @string resource activity_main.xml /test1/res/layout line 42 Android Lint Problem
[I18N] Hardcoded string "Euro to Dollor", should use @string resource activity_main.xml /test1/res/layout line 47 Android Lint Problem
[I18N] Hardcoded string "Calculate", should use @string resource activity_main.xml /test1/res/layout line 53 Android Lint Problem
[I18N] Hardcoded string "DOLLOR", should use @string resource activity_main.xml /test1/res/layout line 18 Android Lint Problem
This text field does not specify an inputType or a hint activity_main.xml /test1/res/layout line 20 Android Lint Problem
[I18N] Hardcoded string "EURO", should use @string resource activity_main.xml /test1/res/layout line 30 Android Lint Problem
This text field does not specify an inputType or a hint activity_main.xml /test1/res/layout line 33 Android Lint Problem
Textview cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 13 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 14 Java Problem
RedioButton cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 15 Java Problem
AbsoluteLayout is deprecated activity_main.xml /test1/res/layout line 2 Android Lint Problem
Textview cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 23 Java Problem
OnClickListner cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 10 Java Problem
Textview cannot be resolved to a type MainActivity.java /test1/src/com/example/test1 line 12 Java Problem
Syntax error, insert "enum Identifier" to complete EnumHeaderName MainActivity.java /test1/src/com/example/test1 line 52 Java Problem
Syntax error, insert "EnumBody" to complete BlockStatement MainActivity.java /test1/src/com/example/test1 line 52 Java Problem
推荐答案
我可以看到你已经非常努力地学习Android,这是值得称道的。为此,我非常乐意花费额外的时间来研究你的问题。
除其他外,还有很多拼写错误和错误的情况,请记住Java是区分大小写的
1. OnClickListner应该是OnClickListener
2. Textview应该是TextView
3. RedioButton应该是RadioButton
4. isCheked应该是isChecked
5.为什么有两个类似的方法:convertDollorToEuro()
6. ...
我根据我的理解创建了一个有效的android项目你的尝试,看看并自己学习。
MainActivity.java
I can see that you have tried very hard to learn Android, that is commendable. For that, I am more than happy to spend extra time looking into your problem.
Among other things, there are many typo errors and wrong cases, remember Java is case-sensitive
1. OnClickListner should be OnClickListener
2. Textview should be TextView
3. RedioButton should be RadioButton
4. isCheked should be isChecked
5. Why two similar methods: convertDollorToEuro()
6. ...
I have created a working android project based on my understanding of your attempt, take a look and learn for yourself.
MainActivity.java
package com.example.test1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
TextView dollar;
TextView euro;
RadioButton dte;
RadioButton etd;
Button calculate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dollar = (TextView) this.findViewById(R.id.dollar);
euro = (TextView) this.findViewById(R.id.euro);
dte = (RadioButton) this.findViewById(R.id.dte);
etd = (RadioButton) this.findViewById(R.id.etd);
calculate = (Button) this.findViewById(R.id.calculate);
calculate.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(dte.isChecked())
{
convertDollarToEuro();
}
else if(etd.isChecked())
{
convertEuroToDollar();
}
}
protected void convertDollarToEuro() {
double val = Double.parseDouble(dollar.getText().toString());
euro.setText(Double.toString(val * 0.7378));
}
protected void convertEuroToDollar() {
double val = Double.parseDouble(euro.getText().toString());
dollar.setText(Double.toString(val * 1.3554));
}
}
activity_main.xml
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- dollar Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dollar"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:textSize="17dip"/>
<!-- input dollar -->
<EditText android:id="@+id/dollar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_marginBottom="15dip"
android:singleLine="true"
android:inputType="numberDecimal"/>
<!-- euro Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Euro"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="10dip"
android:textSize="17dip"/>
<!-- input euro -->
<EditText android:id="@+id/euro"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_marginBottom="15dip"
android:singleLine="true"
android:inputType="numberDecimal"/>
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/dte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dte" />
<RadioButton
android:id="@+id/etd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/etd" />
</RadioGroup>
<Button
android:id="@+id/calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="calculate" />
</LinearLayout>
This program will throw error when both text boxes are blank while clicking the button, I shall leave that to you as exercise.
This program will throw error when both text boxes are blank while clicking the button, I shall leave that to you as exercise.
You have typed RedioButton$ c$c>, it should be RadioButton
.
You have typedRedioButton
, it should beRadioButton
.
这篇关于我是学习Android的新手,我有很多错误,但不知道如何解决这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!