我的应用程序运行良好,直到我进行了一些更改以提高可用性。现在它总是显示这个错误:
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2460
这是我的代码:
package de.nibor.theconverter;
public class MainActivity extends Activity implements OnItemSelectedListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_main);
//Gets all resources you need to get the input measure, calculate and printout the converted measure
final Button convertButton = (Button) findViewById(R.id.convertButton);
final EditText inputEditText = (EditText) findViewById(R.id.inputEditText);
final TextView hintTextView1 = (TextView) findViewById(R.id.hintTextView1);
final TextView hintTextView2 = (TextView) findViewById(R.id.hintTextView2);
final TextView outputTextView1 = (TextView) findViewById(R.id.outputTextView1);
final TextView outputTextView2 = (TextView) findViewById(R.id.outputTextView2);
final CharSequence inches = getResources().getString(R.string.inches);
final CharSequence cm = getResources().getString(R.string.cm);
final CharSequence feet = getResources().getString(R.string.feet);
final CharSequence cm_or_inch_hint_inputEditText = getResources().getString(R.string.cm_or_inch_hint_inputEditText);
final CharSequence cm_to_inch_hintTextView1 = getResources().getString(R.string.cm_to_inch_hintTextView1);
final CharSequence inch_to_cm_hintTextView2 = getResources().getString(R.string.inch_to_cm_hintTextView2);
final CharSequence are = getResources().getString(R.string.are);
final String measure_string = inputEditText.getText().toString();
final Double measure_double = Double.parseDouble(measure_string);
final Spinner measure_unit_spinner = (Spinner) findViewById(R.id.measure_unit_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.measure_units, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
measure_unit_spinner.setAdapter(adapter);
OnItemSelectedListener listener = new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
if(measure_unit_spinner.getSelectedItemPosition() == 0){
inputEditText.setHint(cm_or_inch_hint_inputEditText);
convertButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
printoutConvertedMeasure1();
printoutConvertedMeasure2();
}
private void printoutConvertedMeasure1() {
//first part: if cm convert to inch
hintTextView1.setText(cm_to_inch_hintTextView1);
Double cm_to_inch_decimal = (double) (measure_double/2.54);
Integer cm_to_inch_no_decimal = (int) (cm_to_inch_decimal*100.0);
Double cm_to_inch_output = (double) cm_to_inch_no_decimal/100.0;
outputTextView1.setText(measure_string + " " + cm + are + " " + cm_to_inch_output.toString() + " " + inches);
}
private void printoutConvertedMeasure2() {
//second part: if inch convert to cm
hintTextView2.setText(inch_to_cm_hintTextView2);
Double inch_to_cm_decimal = (double) (measure_double*2.54);
Integer inch_to_cm_no_decimal = (int) (inch_to_cm_decimal*100.0);
Double inch_to_cm_output = (double) (inch_to_cm_decimal/100.0);
outputTextView2.setText(measure_string + " " + cm + are + " " + inch_to_cm_output.toString() + " " + cm);
}
});
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
};
measure_unit_spinner.setOnItemSelectedListener(listener);
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
谁能帮我解决这个错误?(我想创建一个单位转换器应用程序)