help......i am a Beginners

by yoyo » Tue, 14 Apr 2009 00:58:56 GMT

Sponsored Links
 package com.androidyo.firstbmi;

import java.text.DecimalFormat;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Bmi extends Activity {

        /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        Button button=(Button)findViewById(;
    private OnClickListener calcBMI = new OnClickListener()
        public void onClick(View v)
                DecimalFormat nf=new DecimalFormat("0.00");

                EditText fieldheight=(EditText)findViewById(;
                EditText fieldweight = (EditText)findViewById(;
                double height = 
                double weight = 

                TextView result = (TextView)findViewById(;
                TextView fieldsuggest = (TextView)findViewById(;
                        result.setText("input wrong");
                   double BMI = weight / (height * height);

             result.setText("Your BMI is "+nf.format(BMI));

                   }else if(BMI<20){



MY question:

when runing the app .if i input nothing .it will force close

how can i fix it???
please give me a hang...i am a beginners.thanks


help......i am a Beginners

by Marco Nelissen » Tue, 14 Apr 2009 01:10:14 GMT

 You almost no information as to what goes wrong, but my guess is that
since you didn't input any values, the call to Double.parseDouble()
throws an exception.
BTW, since you say you're a beginner, you might want to give the
android-beginners mailing list a try.


Sponsored Links

help......i am a Beginners

by MrChaz » Tue, 14 Apr 2009 01:22:03 GMT

 You need to make sure that there is text in the TextEdits before
calling parseDouble because it will throw an exception otherwise.
Something like:

String heightText = fieldheight.getText().toString();
if( heightText  != null && !heightText.equals("")){
 // do stuff here

should work.


Other Threads

1. About boot.img

I'm trying to guess what are the files that contain the low level code
of the boot.img/recovery.img images. I tried modifying the .S files in
the sub folders of "/bootable/bootloader/legacy/", but after a re-
compilation the boot image are exactly the same as before my edits to
the file(s) (Checked with shasum before & after the re-compilation).
Also, I'm trying to avoid a "make clean", because a full compilation
takes me about 3.5 hours :(

Thank you very much!


2. Feeding Media player from non-rtsp/non-file source

I've mpeg4 source that is not accessible on rtsp protocol. It is not
in a file too. Is there any other data source I can specify to Media
Player? All I know is that it is mpeg4 encoded data as it can be
played with media player when it is fed from RTSP server or played
from files.

Thanks for your help.


3. stock rom erd79

4. Using Surface in the Native Code

5. Zoom Control

6. Ngobrol di IRC yuuk...

7. How to show floating menu similar to sub-menus on screen tap