2月23号学习总结

2月23号学习总结今天继续观看安卓相关教程,以便完成家庭账本的作业packagenet.nell.userregistration;importandroid.content.Intent;importandroid.os.Bundle;importandroid.view.View;importand

大家好,欢迎来到IT知识分享网。2月23号学习总结

今天继续观看安卓相关教程,以便完成家庭账本的作业

package net.nell.userregistration;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class RegistrationActivity extends AppCompatActivity {
private EditText edtName;
private EditText edtSex;
private EditText edtAge;
private EditText edtNumber;
private EditText edtEmail;
private EditText edtMainpage;
private EditText edtRemark;
private Button btnRegistration;
private Button btnCancel;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);

edtName = findViewById(R.id.edtName);
edtSex = findViewById(R.id.edtSex);
edtAge = findViewById(R.id.edtAge);
edtNumber = findViewById(R.id.edtNumber);
edtEmail = findViewById(R.id.edtEmail);
edtMainpage = findViewById(R.id.edtMainpage);
edtRemark = findViewById(R.id.edtRemark);
btnRegistration = findViewById(R.id.btnRegistration);
btnCancel = findViewById(R.id.btnCancel);

btnRegistration.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String strName = edtName.getText().toString().trim();
String strSex = edtSex.getText().toString().trim();
String strAge = edtAge.getText().toString().trim();
String strNumber = edtNumber.getText().toString().trim();
String strEmail = edtEmail.getText().toString().trim();
String strMainpage = edtMainpage.getText().toString().trim();
String strRemark = edtRemark.getText().toString().trim();

Intent intent = new Intent(RegistrationActivity.this,MainActivity.class);
Bundle data = new Bundle();
data.putString(“strName:”,strName);
data.putString(“strSex”,strSex);
data.putString(“strAge”,strAge);
data.putString(“strNumber”,strNumber);
data.putString(“strEmail”,strEmail);
data.putString(“strMainpage”,strMainpage);
data.putString(“strRemark”,strRemark);
intent.putExtras(data);
startActivity(intent);

}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});

}
}

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/34620.html

(0)

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信