Selbstprogrammierte StundenRechner app Schmiert ab


meganoahj

Grünschnabel
Ich hab mit eclipse ne app programiert hier ein screenshot:
ck96.jpg

Diese Schmiert nach druck auf los immer ab!

Hier der code:

MainActivity.java
Code:
package com.heinrichsweikampteam.tcrechner;

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

public class MainActivity extends Activity {

	@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 los (View view) {
	EditText mText = null;
	String text = null;
	
	mText = (EditText) findViewById(R.id.editText2);
	text = mText.getText().toString();
	double volt = Double.valueOf(text);
	
	mText = (EditText) findViewById(R.id.editText5);
	text = mText.getText().toString();
	double Ah = Double.valueOf(text);
	
	mText = (EditText) findViewById(R.id.editText3);
	text = mText.getText().toString();
	double verbrauchwatt = Double.valueOf(text);
	
	mText = (EditText) findViewById(R.id.editText4);
	text = mText.getText().toString();
	double ladungprozent = Double.valueOf(text);
	
	double tauchzeit = (volt * Ah) / verbrauchwatt ;
	tauchzeit = (tauchzeit * ladungprozent)  / 100;
	
	TextView tv = (TextView) findViewById(R.id.textView6);
	tv.setText(Double.toString(tauchzeit));
	
}
}
activity_main.xml
Code:
<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" >

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView3"
        android:layout_alignBottom="@+id/textView3"
        android:layout_alignLeft="@+id/editText4"
        android:text="Ladung (%)" />

    <EditText
        android:id="@+id/editText4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView4"
        android:layout_marginLeft="17dp"
        android:layout_toRightOf="@+id/textView3"
        android:ems="10"
        android:inputType="numberDecimal" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button1"
        android:layout_below="@+id/textView5"
        android:layout_marginTop="40dp"
        android:text=""
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:text="Spannung (V)" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_toLeftOf="@+id/textView7"
        android:ems="10"
        android:inputType="numberDecimal" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/editText1"
        android:layout_toRightOf="@+id/editText3"
        android:text="WattStunden (Wh)" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/editText3"
        android:layout_below="@+id/editText3"
        android:onClick="los"
        android:text="Los" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button1"
        android:layout_below="@+id/button1"
        android:layout_marginTop="19dp"
        android:text="Ergebnis (Stunden)" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textView5"
        android:layout_alignLeft="@+id/textView7"
        android:ems="10"
        android:inputType="numberDecimal" />

    <EditText
        android:id="@+id/editText3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/editText4"
        android:layout_alignBottom="@+id/editText4"
        android:layout_alignParentLeft="true"
        android:ems="10"
        android:inputType="numberDecimal" >

        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/editText2"
        android:layout_marginTop="21dp"
        android:text="Stromverbrauch bei Tauchmodus (Watt)" />

    <EditText
        android:id="@+id/editText5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView4"
        android:layout_below="@+id/textView2"
        android:ems="10"
        android:inputType="numberDecimal" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/editText2"
        android:layout_alignLeft="@+id/editText5"
        android:text="Kapazität (Ah)" />

</RelativeLayout>
bitte um hilfe
lg noah.