Home > Mobile >  New to the Android, write addition process simulation to the phone after flashing back what is ne
New to the Android, write addition process simulation to the phone after flashing back what is ne

Time:09-21

This is MainActivity. Java code
Package com. Example. Myapplication;

import androidx.appcompat.app.AppCompatActivity;

The import android. OS. Bundle;
The import android. View. The view;
import android.widget.Button;
The import android. Widget. TextView;
Import the Java. Lang. String;

Public class MainActivity extends AppCompatActivity {
Private TextView JAVAtext1;
Private TextView JAVAtext2;
Private TextView JAVAtext3;
Private Button JAVAbut;
Private Float num1.
Private Float num2;
Private String str1;
Private String str2;
@ Override
Protected void onCreate (Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
JAVAtext1=(TextView) enclosing the findViewById (R.i which the ext);
JAVAtext2=(TextView) enclosing the findViewById (R.i which however);
JAVAtext3=(TextView) enclosing the findViewById (R.i which ext3);
JAVAbut=(Button) enclosing the findViewById (R.i db ut);
Str1=(String) JAVAtext1. GetText ();
JAVAtext2 str2=(String). The getText ();
Num1=Float. ParseFloat (str1);
Num2=Float. ParseFloat (str2);
JAVAbut. SetOnClickListener (new View. An OnClickListener () {
//@ Overrides
//Float num3=MainActivity. This. Num1.
//Float num4=MainActivity. This. Num2;
Public void onClick (View v) {
//Float. ToString ((num1 + num2))
JAVAtext3. SetText (" Float. ToString (num3 + num4) ");
}
});
}
}

CodePudding user response:

Look at the logcat log

CodePudding user response:

App startup flash back, at the same time the logcat these what does it mean

CodePudding user response:

These is not all right, you carefully check, find the error log

CodePudding user response:

OnCreate cannot do some operations, add a button, instead to do these functions in the button, the interface first run out;

Mean
Delete the
Str1=(String) JAVAtext1. GetText ();
JAVAtext2 str2=(String). The getText ();
Num1=Float. ParseFloat (str1);
Num2=Float. ParseFloat (str2);
This a few words

CodePudding user response:

String. The valueOf (num1 + num2);
  • Related