How can I use EditText Number Format in Math (Android)? -


edittext "number decimal." thought integer use numa square shows me error "change type of "numa" 'double'.
any great appreciated.

edittext numa, numb, numc; numa = (edittext) findviewbyid(r.id.numa); numb = (edittext) findviewbyid(r.id.numb); numc = (edittext) findviewbyid(r.id.numc); double sqrt = (double) (math.pow(numa, 2)); 

hi please try that-

 package com.example.hello;  import android.app.activity; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext;  public class mainactivity extends activity {     edittext editpsw;     button btncheckbox;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         editpsw=(edittext)findviewbyid(r.id.edittext1);         btncheckbox=(button)findviewbyid(r.id.button1);            btncheckbox.setonclicklistener(new onclicklistener() {              @override             public void onclick(view arg0) {                 // todo auto-generated method stub                   double gettext=double.parsedouble(editpsw.gettext().tostring());                     double sqrt = (double) (math.pow(gettext, 2));                     system.out.println(sqrt);              }         });     }    } 

and in layout-

<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"     android:background="@color/white"     tools:context=".mainactivity" >      <edittext         android:id="@+id/edittext1"         android:layout_width="fill_parent"         android:layout_height="30dp"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true"         android:layout_margintop="172dp"         android:ems="10"         android:padding="1dp"         android:inputtype="number" >          <requestfocus />      </edittext>      <button         android:id="@+id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_below="@+id/edittext1"         android:layout_centerhorizontal="true"         android:layout_margintop="66dp"         android:text="button" />  </relativelayout> 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -