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

  • SEARCH
  • Home
  • 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 3456612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:45:29+00:00 2026-05-18T09:45:29+00:00

I am trying to write a simple android application to help interpret some lab

  • 0

I am trying to write a simple android application to help interpret some lab results.

package org.android.bloodgas;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;

public class pinit extends Activity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button interpretButton = (Button) findViewById(R.id.Interpret);

        //interpretButton.setOnClickListener(this);
        View.OnClickListener myhandler = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    float inpPH, inpPO2, inpPCO2, inpHCO3, inpBE;
                    inpPH = Float.valueOf(findViewById(R.id.InpPH).toString()).floatValue();
                    inpPO2 = Float.valueOf(findViewById(R.id.InpO2).toString()).floatValue();
                    inpPCO2 = Float.valueOf(findViewById(R.id.InpCO2).toString()).floatValue();
                    inpHCO3 = Float.valueOf(findViewById(R.id.InpHCO3).toString()).floatValue();
                    inpBE = Float.valueOf(findViewById(R.id.InpBE).toString()).floatValue();

                    TextView interpretation;
                    interpretation = (TextView) findViewById(R.id.Interpretation);

                    String sResult = null;
                    if (inpPH < 7.35) {
                        // Acidosis
                        sResult.concat("Acidosis. ");
                    } else {
                        if (inpPH > 7.45) {
                            // Alkalosis
                            sResult.concat("Alkalosis. ");
                        } else {
                            // Normal acidity, 7.35-7.45
                            sResult.concat("Normal pH. ");
                        }
                    }
                    interpretation.setText(sResult);
            }
        };

        interpretButton.setOnClickListener(myhandler);

    }

}

It does compile and run but when I press on the “interpret” button it simply says The application … has stopped unexpectedly. Please try again. (Force Close).

I am totally new to android programming… So I guess this would be some very stupid mistake I have made but please help. Thanks.

update: changed the code to this (minus the logic portion while i will complete later)
but still hangs when press on the button.

package org.android.bloodgas;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Button;

public class Pinit extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button interpretButton = (Button) findViewById(R.id.Interpret);

        View.OnClickListener myhandler = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    float inpPH, inpPO2, inpPCO2, inpHCO3, inpBE;
                    inpPH = Float.valueOf(((EditText) Pinit.this.findViewById(R.id.InpPH)).toString()).floatValue();
                    inpPO2 = Float.valueOf(((EditText) Pinit.this.findViewById(R.id.InpO2)).toString()).floatValue();
                    inpPCO2 = Float.valueOf(((EditText) Pinit.this.findViewById(R.id.InpCO2)).toString()).floatValue();
                    inpHCO3 = Float.valueOf(((EditText) Pinit.this.findViewById(R.id.InpHCO3)).toString()).floatValue();
                    inpBE = Float.valueOf(((EditText) Pinit.this.findViewById(R.id.InpBE)).toString()).floatValue();
                    // ...
            }
        };

        interpretButton.setOnClickListener(myhandler);

    }

}

logcat:

12-07 03:37:02.231: WARN/dalvikvm(1074): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074): FATAL EXCEPTION: main
12-07 03:37:02.332: ERROR/AndroidRuntime(1074): java.lang.NumberFormatException: android.widget.EditText@44f47e60
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at org.apache.harmony.luni.util.FloatingPointParser.initialParse(FloatingPointParser.java:130)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at org.apache.harmony.luni.util.FloatingPointParser.parseFloat(FloatingPointParser.java:319)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at java.lang.Float.parseFloat(Float.java:291)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at java.lang.Float.valueOf(Float.java:330)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at org.android.bloodgas.Pinit$1.onClick(Pinit.java:22)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at android.view.View.performClick(View.java:2408)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at android.view.View$PerformClick.run(View.java:8816)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at android.os.Handler.handleCallback(Handler.java:587)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at android.os.Looper.loop(Looper.java:123)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at android.app.ActivityThread.main(ActivityThread.java:4627)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at java.lang.reflect.Method.invokeNative(Native Method)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at java.lang.reflect.Method.invoke(Method.java:521)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-07 03:37:02.332: ERROR/AndroidRuntime(1074):     at dalvik.system.NativeStart.main(Native Method)
12-07 03:37:02.382: WARN/ActivityManager(68):   Force finishing activity org.android.bloodgas/.Pinit
12-07 03:37:02.952: WARN/ActivityManager(68): Activity pause timeout for HistoryRecord{44fbfc90 org.android.bloodgas/.Pinit}
12-07 03:37:07.761: INFO/Process(1074): Sending signal. PID: 1074 SIG: 9
12-07 03:37:09.852: INFO/ActivityManager(68): Process org.android.bloodgas (pid 1074) has died.
12-07 03:37:09.862: INFO/WindowManager(68): WIN DEATH: Window{44fa71e0 org.android.bloodgas/org.android.bloodgas.Pinit paused=false}
12-07 03:37:15.931: WARN/ActivityManager(68): Activity destroy timeout for HistoryRecord{44fbfc90 org.android.bloodgas/.Pinit}
  • 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-05-18T09:45:30+00:00Added an answer on May 18, 2026 at 9:45 am

    First thing I see is that you have to cast this to the type of view that it is

    inpPH = Float.valueOf(findViewById(R.id.InpPH).toString()).floatValue();

    Second, you’re calling this from within the onclickListener. So findViewById() really shouldn’t even compile. You need

    inpPH = Float.valueOf((TypeOfView) pinit.this.findViewById(R.id.InpPH).toString()).floatValue();
    

    And also in java, classes should start with capital lettors, so it should be

    public class Pinit extends Activity{

    Update:

    findViewById(R.id.InpPH) resolves to
    EditTex

    No it doesn’t. It resolves to a View. Calling .toString() on a view is not what you want. You want to do

    ((EditText) pinit.this.findViewById(R.id.InpPH)).getText().toString()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.