我有一个应用程序要求提升用户名,体重和体重。该名称收集在一个字符串中,并设置为textview没问题。但是,当我尝试收集体重的数字并将其输出到textview时,应用程序崩溃了。此外,我想发布logcat,但它是十亿行长。我怎样才能更改,以便发布适用的内容?
添加了EDIT-Logcat
logcat的
06-12 21:23:52.839 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:23:52.840 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:23:54.849 1613-1613/? E/NotificationTutorialService﹕ isScreenDisplayed(): false isHomeInForeground: false
06-12 21:23:54.871 28094-28094/? E/dalvikvm﹕ /system/framework/com.motorola.calendarcommon.jar odex has stale dependencies
06-12 21:23:54.882 28094-28094/? E/dalvikvm﹕ /system/priv-app/Calendar.apk odex has stale dependencies
06-12 21:23:55.233 28111-28111/? E/dalvikvm﹕ /system/framework/android.test.runner.jar odex has stale dependencies
06-12 21:23:55.238 28111-28111/? E/dalvikvm﹕ /system/priv-app/CalendarProvider.apk odex has stale dependencies
06-12 21:23:57.842 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:23:57.842 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:00.139 28138-28138/? E/dalvikvm﹕ /system/framework/WfdCommon.jar odex has stale dependencies
06-12 21:24:00.140 28138-28138/? E/dalvikvm﹕ /system/framework/com.motorola.frameworks.core.addon.jar odex has stale dependencies
06-12 21:24:00.172 28138-28138/? E/dalvikvm﹕ /system/framework/am.jar odex has stale dependencies
06-12 21:24:00.178 28138-28138/? E/cutils-trace﹕ Error opening trace file: Permission denied (13)
06-12 21:24:00.385 28138-28138/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
06-12 21:24:00.385 28138-28138/? E/android.os.Debug﹕ failed to load memtrack module: -2
06-12 21:24:01.120 28157-28157/? E/dalvikvm﹕ /system/framework/WfdCommon.jar odex has stale dependencies
06-12 21:24:01.121 28157-28157/? E/dalvikvm﹕ /system/framework/com.motorola.frameworks.core.addon.jar odex has stale dependencies
06-12 21:24:01.149 28157-28157/? E/dalvikvm﹕ /system/framework/am.jar odex has stale dependencies
06-12 21:24:01.158 28157-28157/? E/cutils-trace﹕ Error opening trace file: Permission denied (13)
06-12 21:24:01.316 28157-28157/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
06-12 21:24:01.316 28157-28157/? E/android.os.Debug﹕ failed to load memtrack module: -2
06-12 21:24:02.087 8002-25516/? E/rsC++﹕ RS Message thread exiting.
06-12 21:24:02.844 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:02.845 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:07.846 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:07.846 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:12.748 2465-2481/? E/MC_BatteryUtils﹕ Coulomb counter file not found.
06-12 21:24:12.847 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:12.847 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:14.000 28167-28167/com.th3ramr0d.poundforpound E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.th3ramr0d.poundforpound, PID: 28167
java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:137)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:331)
at com.th3ramr0d.poundforpound.MainActivity$1.onClick(MainActivity.java:48)
at android.view.View.performClick(View.java:4466)
at android.view.View$PerformClick.run(View.java:18537)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
06-12 21:24:14.579 1613-1613/? E/NotificationTutorialService﹕ isScreenDisplayed(): false isHomeInForeground: false
06-12 21:24:17.849 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:17.849 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:22.851 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:22.851 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:27.853 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:27.853 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:32.869 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:32.870 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
06-12 21:24:37.872 415-453/? E/ThermalDaemon﹕ set temp 65000 to name /sys/class/hwmon/hwmon0/device/temp1_max
06-12 21:24:37.872 415-453/? E/ThermalDaemon﹕ set temp -128000 to name /sys/class/hwmon/hwmon0/device/temp1_max_hyst
Java文件
package com.th3ramr0d.poundforpound;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
Button calculate;
EditText inputname1;
EditText inputname2;
EditText inputbodyweight1;
TextView outputname1;
TextView outputname2;
TextView outputratio1;
int inputbodyweight1var = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
calculate = (Button)findViewById(R.id.calculate);
inputname1 = (EditText)findViewById(R.id.inputname1);
inputname2 = (EditText)findViewById(R.id.inputname2);
inputbodyweight1 = (EditText)findViewById(R.id.inputbodyweight1);
outputname1 = (TextView)findViewById(R.id.outputname1);
outputname2 = (TextView)findViewById(R.id.outputname2);
outputratio1 = (TextView)findViewById(R.id.outputratio1);
calculate.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
String inputname1var = inputname1.getText().toString();
String inputname2var = inputname2.getText().toString();
//String inputbodyweight1var = inputbodyweight1.getText().toString();
int inputbodyweight1var = Integer.parseInt(inputbodyweight1.getText().toString());
outputname1.setText(inputname1var);
outputname2.setText(inputname2var);
outputratio1.setText(inputbodyweight1var);
}
}
);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
XML文件
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:focusableInTouchMode="true"
>
<TextView
android:layout_width="175dp"
android:layout_height="wrap_content"
android:text="Name"
android:id="@+id/textView"
android:layout_row="0"
android:layout_column="0" />
<TextView
android:layout_width="175dp"
android:layout_height="wrap_content"
android:text="Body Weight"
android:id="@+id/textView2"
android:layout_row="1"
android:layout_column="0" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/inputbodyweight1"
android:layout_row="1"
android:layout_column="1" />
<TextView
android:layout_width="175dp"
android:layout_height="wrap_content"
android:text="Weight Lifted"
android:id="@+id/textView3"
android:layout_row="2"
android:layout_column="0" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/editText3"
android:layout_row="2"
android:layout_column="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_row="3"
android:layout_column="0" />
<TextView
android:layout_width="175dp"
android:layout_height="wrap_content"
android:text="Name"
android:id="@+id/textView4"
android:layout_row="4"
android:layout_column="0" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
android:id="@+id/inputname2"
android:layout_row="4"
android:layout_column="1" />
<TextView
android:layout_width="175dp"
android:layout_height="wrap_content"
android:text="Body Weight"
android:id="@+id/textView5"
android:layout_row="5"
android:layout_column="0" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/editText5"
android:layout_row="5"
android:layout_column="1" />
<TextView
android:layout_width="175dp"
android:layout_height="wrap_content"
android:text="Weight Lifted"
android:id="@+id/textView6"
android:layout_row="6"
android:layout_column="0" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
android:id="@+id/inputname1"
android:layout_row="0"
android:layout_column="1" />
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/editText6"
android:layout_row="6"
android:layout_column="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="10dp"
android:layout_row="7"
android:layout_column="0" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Calculate"
android:id="@+id/calculate"
android:layout_row="8"
android:layout_column="0"
android:layout_columnSpan="2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="15dp"
android:layout_row="9"
android:layout_column="0" />
<Button
android:id="@+id/reset"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RESET"
android:layout_row="10"
android:layout_column="0"
android:layout_columnSpan="2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/outputname1"
android:layout_row="11"
android:layout_column="0"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/outputname2"
android:layout_row="11"
android:layout_column="1"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ratio"
android:id="@+id/outputratio1"
android:layout_row="12"
android:layout_column="0"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ratio"
android:id="@+id/textView10"
android:layout_row="12"
android:layout_column="1"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView11"
android:layout_row="13"
android:layout_column="0"
android:layout_columnSpan="2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name is stronger than name by xx%"
android:id="@+id/textView12"
android:layout_row="14"
android:layout_column="0"
android:layout_columnSpan="2"
android:layout_gravity="center_horizontal" />
</GridLayout>
</RelativeLayout>