您的位置: 首页 - 站长

DW做的网页用网站打不开哪个网站做自考题目免费

当前位置: 首页 > news >正文

DW做的网页用网站打不开,哪个网站做自考题目免费,杭州网站建设电话,杭州有哪些网站建设一、如何跳转一个活动 左边的是本活动名称#xff0c; 右边的是跳转界面活动名称 Intent intent new Intent(LoginActivity.this, RegisterActivity.class); startActivity(intent); finish(); 二、如果在不同的界面传递参数 //发送消息 SharedPreferences sharedPreferen…一、如何跳转一个活动 左边的是本活动名称 右边的是跳转界面活动名称 Intent intent new Intent(LoginActivity.this, RegisterActivity.class); startActivity(intent); finish(); 二、如果在不同的界面传递参数 //发送消息 SharedPreferences sharedPreferences getSharedPreferences(MyPrefs, MODE_PRIVATE); SharedPreferences.Editor editor sharedPreferences.edit(); editor.putString(username, username); editor.putString(password, password); editor.apply(); //接收消息 SharedPreferences sharedPreferences getSharedPreferences(MyPrefs, MODE_PRIVATE); String savedUsername sharedPreferences.getString(username, ); String savedPassword sharedPreferences.getString(password, ); 三、如何让图片是按钮 ImageButtonandroid:idid/imageButtonandroid:layout_width50dpandroid:layout_height50dpandroid:srcdrawable/s7 / 四、登录界面 1、创建一个LoginActivity类然后创建对应的界面文件.xml 2、注册登录界面并让登录界面其成为主界面 activityandroid:name.LoginActivityandroid:exportedtrueintent-filteraction android:nameandroid.intent.action.MAIN /category android:nameandroid.intent.category.LAUNCHER //intent-filter/activityactivity android:name.MainActivity/activity android:name.RegisterActivity/ 3、书写登录界面 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewandroid:layout_widthwrap_contentandroid:layout_height20dp/LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text账号android:textSize20dp/EditTextandroid:idid/usernameEditTextandroid:layout_width180dpandroid:layout_heightwrap_contentandroid:textSize20dp//LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text密码android:textSize20dp/EditTextandroid:idid/passwordEditTextandroid:layout_width180dpandroid:layout_heightwrap_contentandroid:textSize20dp//LinearLayoutTextViewandroid:layout_widthwrap_contentandroid:layout_height20dp/LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterCheckBoxandroid:idid/rememberPasswordCheckboxandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text记住密码android:layout_gravitystartandroid:layout_marginStart16dpandroid:layout_marginTop8dp/TextViewandroid:layout_width80dpandroid:layout_heightwrap_content/Buttonandroid:idid/zcButtonandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text点击注册 //LinearLayoutTextViewandroid:layout_widthwrap_contentandroid:layout_height20dp/LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterButtonandroid:idid/loginButtonandroid:layout_width200dpandroid:layout_heightwrap_contentandroid:text确认登录 //LinearLayout/LinearLayout 4、书写登录活动代码 package com.example.yaodian;import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;public class LoginActivity extends AppCompatActivity {EditText usernameEditText;EditText passwordEditText;Button loginButton;Button zcButton;CheckBox rememberPasswordCheckbox ;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.login);rememberPasswordCheckbox findViewById(R.id.rememberPasswordCheckbox);usernameEditText findViewById(R.id.usernameEditText);passwordEditText findViewById(R.id.passwordEditText);loginButton findViewById(R.id.loginButton);zcButton findViewById(R.id.zcButton);loginButton.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View view) {String inputUsername usernameEditText.getText().toString();String inputPassword passwordEditText.getText().toString();SharedPreferences sharedPreferences getSharedPreferences(MyPrefs, MODE_PRIVATE);String savedUsername sharedPreferences.getString(username, );String savedPassword sharedPreferences.getString(password, );// 在这里添加登录验证逻辑if (inputUsername.equals(savedUsername) inputPassword.equals(savedPassword)) {Toast.makeText(LoginActivity.this, 登录成功, Toast.LENGTH_SHORT).show();Intent intent new Intent(LoginActivity.this, MainActivity.class);startActivity(intent);finish();// 跳转到 MainActivity 或其他操作} else {new AlertDialog.Builder(LoginActivity.this).setTitle(提示).setMessage(登录失败用户名或密码错误).setPositiveButton(确定, new DialogInterface.OnClickListener() {Overridepublic void onClick(DialogInterface dialog, int which) {}}).show();}}});zcButton.setOnClickListener((l) - {Intent intent new Intent(LoginActivity.this, RegisterActivity.class);startActivity(intent);finish();});// // 监听复选框状态变化 // rememberPasswordCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // Override // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // // 根据复选框状态来处理记住密码逻辑 // if (isChecked) { // // } else { // // } // } // });} } 五、注册界面 同登录界面 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewandroid:layout_widthwrap_contentandroid:layout_height20dp/LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text 账号android:textSize20dp/EditTextandroid:idid/usernameEditTextandroid:layout_width180dpandroid:layout_heightwrap_contentandroid:textSize20dp//LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text 密码android:textSize20dp/EditTextandroid:idid/passwordEditTextandroid:layout_width180dpandroid:layout_heightwrap_contentandroid:textSize20dp//LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text确认密码android:textSize20dp/EditTextandroid:idid/password2EditTextandroid:layout_width180dpandroid:layout_heightwrap_contentandroid:textSize20dp//LinearLayoutTextViewandroid:layout_widthwrap_contentandroid:layout_height50dp/LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalandroid:gravitycenterButtonandroid:idid/registerButtonandroid:layout_width200dpandroid:layout_heightwrap_contentandroid:text确认注册 //LinearLayout/LinearLayout package com.example.yaodian;import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;public class RegisterActivity extends AppCompatActivity {private EditText usernameEditText;private EditText passwordEditText;private EditText password2EditText;private Button registerButton;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.register_activity);usernameEditText findViewById(R.id.usernameEditText);passwordEditText findViewById(R.id.passwordEditText);password2EditText findViewById(R.id.password2EditText);registerButton findViewById(R.id.registerButton);registerButton.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View view) {String username usernameEditText.getText().toString().trim();String password passwordEditText.getText().toString().trim();String password2 password2EditText.getText().toString().trim();if (username.isEmpty() || password.isEmpty()) {// 弹出“请输入账号和密码”的对话框new AlertDialog.Builder(RegisterActivity.this).setTitle(提示).setMessage(请输入账号和密码).setPositiveButton(确定, null).show();} else if (!password.equals(password2)) {// 弹出“两次密码不一样请重新输入”的对话框new AlertDialog.Builder(RegisterActivity.this).setTitle(提示).setMessage(两次密码不一样请重新输入).setPositiveButton(确定, new DialogInterface.OnClickListener() {Overridepublic void onClick(DialogInterface dialog, int which) {// 清空密码和确认密码输入框passwordEditText.setText();password2EditText.setText();}}).show();} else {// 保存注册信息到 SharedPreferencesSharedPreferences sharedPreferences getSharedPreferences(MyPrefs, MODE_PRIVATE);SharedPreferences.Editor editor sharedPreferences.edit();editor.putString(username, username);editor.putString(password, password);editor.apply();Toast.makeText(RegisterActivity.this, 注册成功, Toast.LENGTH_SHORT).show();Intent intent new Intent(RegisterActivity.this, LoginActivity.class);startActivity(intent);finish();}}});} } 六、完整工程代码 链接https://pan.baidu.com/s/13tm-AsAsJEmfJjbwyX0a3Q 提取码生日 需要提取码的 加QQ:1482728006说明来意付费即可获取工程