Note that there are some explanatory texts on larger screens.

plurals
  1. POfirst android application gives error
    primarykey
    data
    text
    <p>I am new developer in Android and unfortunately my first app is giving an error. I am developing a simple temperature converter.</p> <p>These are the files.</p> <p>AndroidManifest.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.tempconv" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.tempconv.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>activity_main.xml:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" &gt; &lt;EditText android:id="@+id/ipdata" android:hint="Enter temperature" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="22dp" android:ems="10" /&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/ipdata" android:layout_below="@+id/ipdata" android:layout_marginTop="15dp" android:text="Select Conversion" /&gt; &lt;RadioButton android:id="@+id/ctof" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1" android:layout_marginLeft="25dp" android:layout_marginTop="18dp" android:text="Celsius to Feherenhit" /&gt; &lt;RadioButton android:id="@+id/ftoc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/ctof" android:layout_below="@+id/ctof" android:text="Feherenhit to Celsius" /&gt; &lt;EditText android:id="@+id/opdata" android:hint="Hit below button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/ftoc" android:layout_marginTop="54dp" android:ems="10" /&gt; &lt;Button android:id="@+id/doconvert" android:onClick="docon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/opdata" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" android:text="convert" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>MainActivity.java:</p> <pre><code>package com.example.tempconv; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.EditText; import android.widget.RadioButton; public class MainActivity extends Activity { RadioButton RD1 = (RadioButton) findViewById(R.id.ctof); RadioButton RD2 = (RadioButton) findViewById(R.id.ftoc); EditText input = (EditText) findViewById(R.id.ipdata); EditText output = (EditText) findViewById(R.id.opdata); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } public void doconvert(View v) { float data = Float.parseFloat(input.toString()); if (RD1.isChecked()){ float c; c = (data-32)*(5/9); output.setText(String.valueOf(c)); } else if (RD2.isChecked()){ float f; f=(data*(9/5))+32; output.setText(String.valueOf(f)); } } } </code></pre> <p>I checked lots of thread here but dint get solution yet.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload