品牌创意网站建设徕卡eWordPress站点地址填错
- 作者: 五速梦信息网
- 时间: 2026年03月21日 10:15
当前位置: 首页 > news >正文
品牌创意网站建设徕卡e,WordPress站点地址填错,微信公众平台申请入口,90设计网站怎么绑定手机号目录 前言#xff1a;基础夯实#xff1a;效果展示#xff1a;核心代码#xff1a;网盘源码#xff1a; 前言#xff1a; 熟悉安卓开发的基础知识#xff0c;了解#xff0c;弹窗#xff0c;两个页面进行跳转#xff0c;页面的布局#xff0c;按钮#xff0c;文本… 目录 前言基础夯实效果展示核心代码网盘源码 前言 熟悉安卓开发的基础知识了解弹窗两个页面进行跳转页面的布局按钮文本框的使用初学安卓不足之处见谅 基础夯实 对于初学安卓开发的你来说掌握以下基础知识是非常重要的包括Activity的生命周期、页面布局、弹窗、页面跳转、按钮以及文本框的使用等。下面我将逐一介绍这些知识点 一、Activity的生命周期 Activity是Android应用中的单个屏幕它包含了用户可以与之交互的UI元素。了解Activity的生命周期对于开发高质量的Android应用至关重要。Activity的生命周期包括以下几个主要阶段 onCreate()Activity被创建时调用用于初始化Activity的基本状态如加载布局、初始化变量等。 onStart()Activity对用户可见时调用。 onResume()Activity开始与用户交互时调用。 onPause()当Activity失去焦点但仍然可见时如另一个非全屏或透明的Activity被放置在它上面时调用。 onStop()当Activity完全不可见时调用。 onDestroy()Activity即将被销毁时调用此时应释放Activity所占用的资源。 二、页面布局 Android提供了多种布局方式来组织UI元素包括线性布局LinearLayout、约束布局ConstraintLayout、表格布局TableLayout、帧布局FrameLayout和相对布局RelativeLayout等。每种布局都有其特定的使用场景和优势 线性布局将子视图按照水平或垂直方向排列。 约束布局通过约束来定义子视图之间的关系允许创建大型且复杂的布局同时保持层次结构的扁平化。 表格布局用于以行和列的形式组织界面类似于HTML中的表格。 帧布局用于存放单个子视图通常用于包裹一个单独的子视图特别是当需要在运行时替换界面元素时。 相对布局子视图的位置是相对于布局或其他子视图的位置来确定的提供了更大的灵活性。 三、弹窗 在Android中弹窗通常用于向用户显示信息或获取用户的输入。常用的弹窗类型包括AlertDialog、Custom Dialog和PopupWindow等 AlertDialog用于显示一个简单的对话框可以包含标题、消息、图标和按钮等。 Custom Dialog当你需要更复杂的布局或功能时可以创建一个自定义的Dialog。这通常涉及继承Dialog类或DialogFragment并在其中定义自己的布局和行为。 PopupWindow一个可以在当前活动上浮动的小窗口不会自动管理生命周期因此需要自己处理显示和隐藏。 四、页面跳转 在Android应用中页面跳转通常通过Intent来实现。Intent是一个消息传递对象它可以用于请求另一个应用组件执行指定的操作。使用Intent进行页面跳转时需要在AndroidManifest.xml文件中注册目标Activity。Intent可以显式地指定目标组件也可以隐式地根据动作Action和数据Data来匹配目标组件。 五、按钮的使用 按钮是Android应用中最常用的用户界面元素之一。它允许用户通过点击或触摸来触发操作。在Android中按钮是通过使用Button类创建的。你可以在XML布局文件中使用标签来定义按钮也可以在Java代码中通过调用Button类的构造函数来创建按钮。为了处理按钮点击事件你需要为按钮设置点击事件监听器并在监听器中编写相应的处理逻辑。 六、文本框的使用 文本框在Android开发中通常使用EditText控件来实现。EditText控件允许用户输入和编辑文本。你可以在XML布局文件中添加EditText控件并设置其属性如宽度、高度、提示文本等。在Java代码中你可以通过findViewById方法获取布局中定义的EditText控件并获取用户输入的文本内容。此外你还可以为EditText控件设置输入类型如密码、数字等、最大输入长度等属性并为其添加文本改变监听器以便在文本改变时执行特定的操作。 综上所述掌握以上基础知识是初学安卓开发的重要一步。通过不断学习和实践你将能够逐步提高自己的安卓开发能力并开发出高质量的Android应用。 效果展示 安卓例程3 核心代码 主函数 package com.example.test05;import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity;import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import android.widget.Toast;import com.example.test05.util.ViewUtil;import java.util.Random;public class LoginMainActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {private TextView tv_password;private EditText et_password;private Button btn_forget;private CheckBox ck_remember;private EditText et_phone;private RadioButton rb_password;private RadioButton rb_verifycode;private static final int REQUEST_CODE 1; // 定义请求码private Button btn_login;private String mPassword 123456;private String mverifyCode;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_login_main);RadioGroup rb_login findViewById(R.id.rg_login);tv_password findViewById(R.id.tv_password);et_password findViewById(R.id.et_password);et_phone findViewById(R.id.et_phone);btn_forget findViewById(R.id.btn_forget);ck_remember findViewById(R.id.ck_remember);//给rg_login设置单选监听器rb_login.setOnCheckedChangeListener(this);//给et_phone添加文本变更监听器et_phone.addTextChangedListener(new HideTextWatcher(et_phone,11));et_password.addTextChangedListener(new HideTextWatcher(et_password,6));btn_forget.setOnClickListener(this);rb_password findViewById(R.id.rb_password);rb_verifycode findViewById(R.id.rb_verifycode);btn_login findViewById(R.id.btn_login);btn_login.setOnClickListener(this);}Overridepublic void onCheckedChanged(RadioGroup group, int checkedId) {switch (checkedId){case R.id.rb_password:tv_password.setText(getString(R.string.login_password));et_password.setHint(getString(R.string.input_password));btn_forget.setText(getString(R.string.forget_password));ck_remember.setVisibility(View.VISIBLE);break;case R.id.rb_verifycode:tv_password.setText(getString(R.string.verifycode));et_password.setHint(getString(R.string.input_verifycode));btn_forget.setText(getString(R.string.get_verifycode));ck_remember.setVisibility(View.GONE);break;}}Overridepublic void onClick(View v) {String phone et_phone.getText().toString();if(phone.length() 11){Toast.makeText(this,请输入正确的手机号码,Toast.LENGTH_SHORT).show();return;}switch (v.getId()){case R.id.btn_forget:if(rb_password.isChecked()){Intent intent new Intent(this ,LoginForgetActivity.class);Bundle bundle new Bundle();bundle.putString(phone,phone );intent.putExtras(bundle);startActivityForResult(intent, REQUEST_CODE); // 传递intent和请求码}else if (rb_verifycode.isChecked()){//生成六位随机的验证码mverifyCode String.format(%06d,new Random().nextInt(99999));//弹出提醒对话框提示用户记住六位验证码数字AlertDialog.Builder builder new AlertDialog.Builder(this);builder.setMessage(手机号 phone 本次验证码是 mverifyCode 请输入验证码);builder.setPositiveButton(haod,null);AlertDialog dialog builder.create();dialog.show();}break;case R.id.btn_login:if(rb_password.isChecked()){if(!mPassword.equals(et_password.getText().toString())){Toast.makeText(this,请输入你的密码,Toast.LENGTH_SHORT).show();return;}//提示用户登录成功loginSuccess();}else if(rb_verifycode.isChecked())if(!mverifyCode.equals(et_password.getText().toString())){Toast.makeText(this,请输入正确的验证码,Toast.LENGTH_SHORT).show();return;}loginSuccess();break;}}private void loginSuccess() {String desc String.format(你的手机号码%s,et_phone.getText().toString());AlertDialog.Builder builder new AlertDialog.Builder((this));builder.setTitle(登录成功);builder.setMessage(desc);builder.setPositiveButton(确定返回, new DialogInterface.OnClickListener() {Overridepublic void onClick(DialogInterface dialog, int which) {finish();}});builder.setNegativeButton(我再看看,null);AlertDialog dialog builder.create();dialog.show();}private class HideTextWatcher implements TextWatcher {private EditText mView;private int mMaxLength;public HideTextWatcher(EditText v, int maxLength) {this.mView v;this.mMaxLength maxLength;}Overridepublic void beforeTextChanged(CharSequence s, int start, int count, int after) {}Overridepublic void onTextChanged(CharSequence s, int start, int before, int count) {}Overridepublic void afterTextChanged(Editable s) {String str s.toString();if (str.length() mMaxLength ){//隐藏输入法ViewUtil.hideOneIputMehod(LoginMainActivity.this,mView);}}} 布局文件 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalRadioGroupandroid:idid/rg_loginandroid:layout_widthmatch_parentandroid:layout_heightdimen/item_layout_heightandroid:orientationhorizontalRadioButtonandroid:idid/rb_passwordandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1android:textstring/login_by_passwordandroid:textColorcolor/blackandroid:textSizedimen/common_font_size/RadioButtonandroid:idid/rb_verifycodeandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1android:textstring/login_by_verifycodeandroid:textColorcolor/blackandroid:textSizedimen/common_font_size //RadioGroupLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightdimen/item_layout_heightTextViewandroid:layout_widthwrap_contentandroid:layout_heightmatch_parentandroid:gravitycenterandroid:textstring/phone_numberandroid:textColorcolor/blackandroid:textSizedimen/common_font_size/EditTextandroid:idid/et_phoneandroid:layout_width0dpandroid:layout_weight1android:layout_heightmatch_parentandroid:layout_marginTop5dpandroid:layout_marginBottom5dpandroid:hintstring/input_phone_numberandroid:inputTypenumberandroid:maxLength11android:textColorcolor/blackandroid:textColorHintcolor/greyandroid:textSizedimen/common_font_size//LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightdimen/item_layout_heightTextViewandroid:idid/tv_passwordandroid:layout_widthwrap_contentandroid:layout_heightmatch_parentandroid:gravitycenterandroid:textstring/login_by_passwordandroid:textColorcolor/blackandroid:textSizedimen/common_font_size/RelativeLayoutandroid:layout_width0dpandroid:layout_heightmatch_parentandroid:layout_weight1EditTextandroid:idid/et_passwordandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:layout_marginTop5dpandroid:layout_marginBottom5dpandroid:layout_weight1android:hintstring/input_passwordandroid:inputTypenumberPasswordandroid:maxLength11android:textColorcolor/blackandroid:textColorHintcolor/greyandroid:textSizedimen/common_font_size /Buttonandroid:idid/btn_forgetandroid:layout_widthwrap_contentandroid:layout_heightmatch_parentandroid:layout_alignParentEndtrueandroid:textstring/forget_passwordandroid:layout_alignParentRighttrueandroid:textColorcolor/blackandroid:textColorHintcolor/greyandroid:textSizedimen/common_font_size//RelativeLayout/LinearLayoutCheckBoxandroid:idid/ck_rememberandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textstring/remember_passwordandroid:textColorcolor/blackandroid:textSizedimen/common_font_size/Buttonandroid:idid/btn_loginandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textstring/loginandroid:textColorcolor/blackandroid:textSizedimen/button_font_size//LinearLayout网盘源码 链接 https://pan.baidu.com/s/1N44A4YlV1SEVvacc8jTP3w?pwdsawu提取码: sawu
相关文章
-
品牌策划网站建设防静电产品东莞网站建设技术支持
品牌策划网站建设防静电产品东莞网站建设技术支持
- 技术栈
- 2026年03月21日
-
品牌餐饮加盟网站建设手机版网页
品牌餐饮加盟网站建设手机版网页
- 技术栈
- 2026年03月21日
-
品牌宝正式推出免费个人网站认证深圳展台制作公司
品牌宝正式推出免费个人网站认证深圳展台制作公司
- 技术栈
- 2026年03月21日
-
品牌的佛山网站建设价格毕业设计做企业门户网站
品牌的佛山网站建设价格毕业设计做企业门户网站
- 技术栈
- 2026年03月21日
-
品牌官方网站建设郑州 网站建设有限公司
品牌官方网站建设郑州 网站建设有限公司
- 技术栈
- 2026年03月21日
-
品牌建设公司排名济南seo整站优化价格
品牌建设公司排名济南seo整站优化价格
- 技术栈
- 2026年03月21日






