Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:51:17+00:00 2026-06-18T06:51:17+00:00

while running the temperatureconverter app… in the following lines of TemperatureConverter.java setContentView(R.layout.main); text =

  • 0

while running the temperatureconverter app… in the following lines of TemperatureConverter.java

setContentView(R.layout.main); 
text = (EditText) findViewById(R.id.editText1); 
RadioButton celsiusButton = (RadioButton) findViewById(R.id.radio0); 
RadioButton fahrenheitButton = (RadioButton) findViewById(R.id.radio1); 

im getting the following 4 errors :

  • main cannot be resolved or is not a field
  • editText1 cannot be resolved or is not a field
  • radio0 cannot be resolved or is not a field
  • radio1 cannot be resolved or is not a field

please help me out to solve these errors.i hav this as my assignment project . so pls….
the entire source code of the app is been given below.

1.main.xml


<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/myshape"
android:orientation="vertical" > 

<EditText 
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberSigned" > 
<requestFocus/>
</EditText> 

<RadioGroup 
android:id="@+id/radioGroup1"
android:layout_width="match_parent"
android:layout_height="wrap_content" > 

<RadioButton 
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/celsius" > 
</RadioButton> 

<RadioButton 
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fahrenheit" > 
</RadioButton> 
</RadioGroup> 

<Button 
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/calc" 
android:onClick="myClickHandler"> 
</Button> 

</LinearLayout>



3.)  res/drawable/myshape.xml:
    <?xml version="1.0" encoding="UTF-8"?> 
<shape 
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> 
<stroke 
android:width="2dp"
android:color="#FFFFFFFF" /> 
<gradient 
android:endColor="#DDBBBBBB"
android:startColor="#DD777777"
android:angle="90" /> 
<corners 
android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp" /> 
</shape>

4.) res/values/strings.xml:

<resources> 

<string name="hello_world">Hello world!</string> 
<string name="menu_settings">Settings</string> 
<string name="title_activity_convert_temperture_example">ConvertTempertureExample</string> 
<string name="app_name">Temparature Converter</string> 
<color name="myColor">#3399CC</color> 
<string name="myClickHandler">myClickHandler</string> 
<string name="celsius">to Celsius</string> 
<string name="fahrenheit">to Fahrenheit</string> 
<string name="calc">Calculate</string> 

</resources>



5.) TemperatureConverter.java file 
package com.example.TemperatureConverter; 
import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.EditText; 
import android.widget.RadioButton;

import android.widget.RadioGroup; 
import android.widget.Toast; 
   import android.R;
public class TempertureConverter extends Activity 
{ 
private EditText text; 

@Override
public void onCreate(Bundle savedInstanceState)
 { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.main); 
text = (EditText) findViewById(R.id.editText1); 

} 

// This method is called at button click because we assigned the name to the 
// "On Click property" of the button 
public void myClickHandler(View view) 
{ 
        switch (view.getId()) 
       { 
        case R.id.button1: 
RadioButton celsiusButton = (RadioButton) findViewById(R.id.radio0); 
RadioButton fahrenheitButton = (RadioButton) findViewById(R.id.radio1); 
if (text.getText().length() == 0) 
{ 
 Toast.makeText(this, "Please enter a valid number", 
                                Toast.LENGTH_LONG).show(); 
             return; 
} 

float inputValue = Float.parseFloat(text.getText().toString()); 
if (celsiusButton.isChecked())
 { 
text.setText(String 
.valueOf(convertFahrenheitToCelsius(inputValue))); 
celsiusButton.setChecked(false); 
fahrenheitButton.setChecked(true); 
} else { 
text.setText(String 
.valueOf(convertCelsiusToFahrenheit(inputValue))); 
fahrenheitButton.setChecked(false); 
celsiusButton.setChecked(true); 
} 
break; 
} 
} 

 // Converts to celsius 
private float convertFahrenheitToCelsius(float fahrenheit) 
{ 
return ((fahrenheit - 32) * 5 / 9); 
} 

 // Converts to fahrenheit 
private float convertCelsiusToFahrenheit(float celsius)
 { 
return ((celsius * 9) / 5) + 32; 
} 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:51:18+00:00Added an answer on June 18, 2026 at 6:51 am

    You’re importing the wrong R file:

    import android.R;
    

    Remove the above line from your code and replace it with an import of your project’s R file (probably com.example.TemperatureConverter.R)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While running java app from console i got an exception, that contains following line:
While running following code, my program crashes unexpectedly! #include<stdio.h> #include<string.h> int main(){ char *str
I am getting this error While running this LoadError: Expected /home/user/Desktop/Tripurari/myapp/app/models/host.rb to define Host##
I got the following error while running my perl script with the negative lookaround
How to hide cmd window while running a batch file? I use the following
While running tests test runner hangs up on next code "main" prio=10 tid=0x097f4c00 nid=0x7d6a
Im getting following error while running the query. org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'LIMIT' near
While running debugger, the program pauses on initializing object streams from server main input
while running my application I get the following error: javax.el.ELException: /view/doi/common/navigation.xhtml: Can't find bundle
while running rake db:migrate i get the following error : rake db:migrate (in /Users/hrastogi/ruby_project/contactlist)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.