博客主页
标签

Android

下的文章

Count:

计 9 篇
123
Android简单页面跳转+提示弹窗
Android简单页面跳转+提示弹窗
分类: 技术
简介:layout部分shixun_3(跳转页面) - 隐藏 - day4(点击实现跳转) - 隐藏 - main部分MainActivity这里只截取了主要部分 - 隐藏 - shixun_3 - 隐藏 - 注册 <activity android:name=".shixun_3"></activity>
122
Android简单页面跳转
Android简单页面跳转
分类: 技术
简介:代码结构本次项目需要添加的“代码块”如下 👇 layout部分login(登录页面)<?xml version="1.0" encoding="utf 8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|bottom"> <ImageView android:layout_marginTop="100dp" android:layout_width="200dp" android:layout_height="100dp" android:src="@drawable/lxy" android:scaleType="centerCrop"/> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="灵心云·登录" android:textSize="20dp" android:gravity="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="15dp"> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="请输入用户名" android:textSize="18dp" android:background="@drawable/button_round" android:padding="10dp" /> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="输入用户密码" android:textSize="18dp" android:password="true" android:background="@drawable/button_round" android:padding="10dp" android:layout_marginTop="15dp" tools:ignore="Deprecated" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/bt1" android:layout_width="150dp" android:layout_height="wrap_content" android:text="登录" android:textSize="20dp" android:padding="10dp" android:textColor="#ffffff" android:background="@drawable/button_round2" android:layout_marginLeft="30dp" android:layout_marginRight="15dp"/> <Button android:id="@+id/bt2" android:layout_width="150dp" android:layout_height="wrap_content" android:text="注册" android:textSize="20dp" android:padding="10dp" android:textColor="#ffffff" android:background="@drawable/button_round2" android:layout_marginLeft="10dp" android:layout_marginRight="30dp"/> </LinearLayout> </LinearLayout>register(注册页面)<?xml version="1.0" encoding="utf 8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|bottom"> <ImageView android:layout_marginTop="100dp" android:layout_width="200dp" android:layout_height="100dp" android:src="@drawable/lxy" android:scaleType="centerCrop"/> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="灵心云·注册" android:textSize="20dp" android:gravity="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="15dp"> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="请输入用户名" android:textSize="18dp" android:background="@drawable/button_round" android:padding="10dp" /> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="输入用户密码" android:textSize="18dp" android:password="true" android:background="@drawable/button_round" android:padding="10dp" android:layout_marginTop="15dp" tools:ignore="Deprecated" /> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="再次输入密码" android:textSize="18dp" android:password="true" android:background="@drawable/button_round" android:padding="10dp" android:layout_marginTop="15dp" tools:ignore="Deprecated" /> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="输入邮箱地址" android:textSize="18dp" android:background="@drawable/button_round" android:padding="10dp" android:layout_marginTop="15dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/bt4" android:layout_width="150dp" android:layout_height="wrap_content" android:text="立即注册" android:textSize="20dp" android:padding="10dp" android:textColor="#ffffff" android:background="@drawable/button_round2" android:layout_marginLeft="30dp" android:layout_marginRight="15dp"/> <Button android:id="@+id/bt5" android:layout_width="150dp" android:layout_height="wrap_content" android:text="返回登录" android:textSize="20dp" android:padding="10dp" android:textColor="#ffffff" android:background="@drawable/button_round2" android:layout_marginLeft="10dp" android:layout_marginRight="30dp"/> </LinearLayout> </LinearLayout>home(首页)<?xml version="1.0" encoding="utf 8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:text="这是首页" android:textSize="100dp"/> </LinearLayout>drawable部分lxy.png用于装饰的图片,自己随便加一张button_round - 隐藏 - button_round2 - 隐藏 - main部分这里作者是自己全部粘贴过来了,代码中我已经做了相关注释,可以自己慢慢打,注意多用快捷键MainActivity - 隐藏 - 给登录页面(login)加一个判断 - 隐藏 - home_1 - 隐藏 - register_1 - 隐藏 - AndroidManifest部分添加注册 - 隐藏 - 到这里基本上就OK了。如果你是Android studio,可能需要进行下面的配置如果你的登录/注册不是下面这个样子,你需要vaues >themes替换代码 👇 - 隐藏 - 替换位置👇 - 隐藏 -
137
Android简单加运算
Android简单加运算
分类: 技术
简介:calculate「layout部分」<?xml version="1.0" encoding="utf 8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <EditText android:id="@+id/et1" android:layout_width="200dp" android:layout_height="50dp" android:hint="请输入数字" android:textSize="20sp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="+" android:textSize="20sp"/> <EditText android:id="@+id/et2" android:layout_width="200dp" android:layout_height="50dp" android:hint="请输入数字" android:textSize="20sp"/> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="计算" android:textSize="20sp"/> <TextView android:id="@+id/txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textSize="20sp"/> </LinearLayout>MainActivity变量private EditText et1,et2; private TextView txt;计算//获取页面中组件对象 et1=(EditText) findViewById(R.id.et1); et2=(EditText) findViewById(R.id.et2); txt=(TextView) findViewById(R.id.txt); Button button=(Button) findViewById(R.id.btn); //添加监听事件 button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { int sum,num1,num2; if (et1.getText().toString().length()>0&&et2.getText().toString().length()>0){ num1=Integer.parseInt(et1.getText().toString()); num2=Integer.parseInt(et2.getText().toString()); sum=num1+num2; txt.setText(String.valueOf(sum)); }else { Toast.makeText(MainActivity.this,"没有输入数值",Toast.LENGTH_LONG).show(); } } });
222
按钮点击变色
按钮点击变色
分类: 技术
简介:示例drawable部分<?xml version="1.0" encoding="utf 8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <! 按钮被点击时 > <item android:state_pressed="true" android:color="#ff0000"></item> <! 按钮默认状态 > <item android:color="#fff"></item> </selector>
博客主页 数据猫 漫游于星空的数据猫
技术支持 CC 数据猫. 2025
打赏图
打赏博主
欢迎
欢迎
欢迎访问数据猫
搜 索
足 迹
分 类
  • 简文
  • 技术
  • 娱乐