Home > Mobile >  Rookie help Daniel ~ there is no error code but don't run just began to learn android
Rookie help Daniel ~ there is no error code but don't run just began to learn android

Time:09-17


Public class MainActivity extends AppCompatActivity implements the View. An OnClickListener, RadioGroup. OnCheckedChangeListener {
//variable definition
Private String str_phone=", "str_pwd=" ";
Private String str_sex="male";
Private String str_hobby="";
Private String str_city="";
Private String str_result="";
Private String [] city={" Beijing ", "Shanghai", "guangzhou", "shenzhen"};

//component definition
Private EditText etPhoneNo etPwd;
Private RadioGroup rgSex;
Private RadioButton rbMale rbFeMale;
Private CheckBox cbRead cbSing, cbPlay;
Private Spinner Spinner.
Private Button btnLogin;
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();

}

Private void init () {
EtPhoneNo=(EditText) the findViewById (R.i d.e tPhoneNo);
EtPwd=(EditText) the findViewById (R.i d.e tPwd);
RgSex=(RadioGroup) the findViewById (R.i d.r gSex);
RgSex. SetOnCheckedChangeListener (this);
RbMale=(RadioButton) the findViewById (R.i d.r bMale);
RbFeMale=(RadioButton) the findViewById (R.i d.r bFeMale);
CbPlay=(CheckBox) the findViewById (R.i, dc hkplay);
CbRead=(CheckBox) the findViewById (R.i, dc hkRead);
CbSing=(CheckBox) the findViewById (R.i, dc hkmusic);
Spinner=(spinner) the findViewById (R.i d.s pinner);
BtnLogin=(Button) the findViewById (R.i db tnLogin);
BtnLogin. SetOnClickListener (this);
ArrayAdapter adapter=new ArrayAdapter (this, android R.l ayout. Simple_expandable_list_item_1, city);
Spinner. SetAdapter (adapter);
Spinner. SetOnItemClickListener (new AdapterView. OnItemClickListener () {
@ Override
Public void onItemClick (AdapterView<?> The parent, View View, int position, long id) {
Str_city=city [position];
}
});
}

@ Override
Public void onClick (View View) {
The switch (the getId ()) {
Case R.i db tnLogin:
Str_hobby="";
Str_phone=etPhoneNo. GetText (). The toString ();
Str_pwd=etPwd. GetText (). The toString ();
If (cbRead isChecked ())
Str_hobby +=cbRead. GetText (). The toString () + "";
If (cbPlay isChecked ())
Str_hobby +=cbPlay. GetText (). The toString () + "";
If (cbSing isChecked ())
Str_hobby +=cbSing. GetText (). The toString () + "";
Intent Intent=new Intent (MainActivity. This, SecondActivity. Class);
Bundle Bundle=new Bundle ();
Bundle. PutString (" phone ", str_phone);
Bundle. PutString (" PWD ", str_pwd);
Bundle. PutString (" sex ", str_sex);
Bundle. PutString (" hobby ", str_hobby);
Bundle. PutString (" city ", str_city);
Intent. PutExtras (bundle);
startActivity(intent);
break;

}

}

@ Override
Public void onCheckedChanged (RadioGroup group, int checkedId) {
If (checkedId==R.i d.r bMale) {
Str_sex="boys";
} else {
Str_sex="girls";
}

}
}
Interface to do no problem when I can open my listening these in and you can't open the app
No display error has been keep stopping

CodePudding user response:

Look at your logcat log, there must be an error, can't you just restore again, and then a little bit of code, to which an error

CodePudding user response:

reference 1st floor BDMH response:
see your logcat log, there must be an error, then no you back first, and then a little bit of code, see to which an error



2020/4/4
Thus * daemon not running; Starting now at TCP: 5037

Thus * daemon started successfully

Thus Gradle sync started with single - the variant sync

Thus the Project setup started

Thus Gradle sync finished in 1 s 74 ms (from cached state)

Thus Executing tasks: [: app: generateDebugSources] project in D: \ Zhongjizuoye

Thus the NDK Resolution Outcome: the Project Settings: Gradle model version=5.4.1, the NDK version is UNKNOWN

Thus the IDE and Plugin Updates: Android Studio is ready to update.

Thus Gradle build finished in 19 s 416 ms

Fell Executing tasks: [the clean, : app: assembleDebug] project in D: \ Zhongjizuoye

At Gradle build finished in 27 s 409 ms

At Executing tasks: [: app: assembleDebug] project in D: \ Zhongjizuoye

At Gradle build finished 9 s in 425 ms

At the Install successfully finished in 1 s 995 ms.
Can't find the problem

CodePudding user response:

This is not a logcat

CodePudding user response:

The adb on
Under the CMD adb logcat & gt; The log. The log log run your apk. Open the log stick the corresponding log out

CodePudding user response:

Logcat there will be a Java program errors that message
  • Related