Click here to Skip to main content
15,900,615 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
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
Posted

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
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.
 
Share this answer
 
v8
Comments
Rajnish D mishra 30-Jan-14 14:17pm    
thnx Peter Leow
really i doing more mistake but through ur help i understand clearly u r good programmer....thnx a lot
Rajnish D mishra 30-Jan-14 14:23pm    
please i have one request from u give me any link for android where i larn
Peter Leow 30-Jan-14 21:51pm    
check this out: http://www.coreservlets.com/android-tutorial/
and keep it up.
Rajnish D mishra 31-Jan-14 1:32am    
thnx
Peter Leow 5-Feb-14 7:24am    
I have spent much time to solve your woe, why are you not accepting this as solution?
You have typed RedioButton, it should be RadioButton.
 
Share this answer
 
Comments
Rajnish D mishra 30-Jan-14 7:13am    
RadioButton cannot be resolved to a type MainActivity.java/test1/src/com/example/test1 line 27 Java
i correct my misstep
but this error what say how i resolve to type
Richard MacCutchan 30-Jan-14 7:22am    
Read what I have posted above; there is no such type as RedioButton.
Rajnish D mishra 30-Jan-14 14:14pm    
thnx bro

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900