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

手机网站 微信怎么自己弄一个平台

手机网站 微信,怎么自己弄一个平台,网站制作电话,网站维护中是不是关闭网站了第三次作业 - 登录注册页面 题目要求 嵌套布局。使用线性布局的嵌套结构,实现登录注册的页面。(例4-3) 创建空的Activity 项目结构树如下图所示: 注意:MainActivity.java文件并为有任何操作,主要功能集中…

第三次作业 - 登录注册页面

题目要求

嵌套布局。使用线性布局的嵌套结构,实现登录注册的页面。(例4-3)

创建空的Activity

项目结构树如下图所示:

image-20231027223632461

注意:MainActivity.java文件并为有任何操作,主要功能集中在LoginActivity和SignUpActivity两个Activity中。

创建LoginActivity和SignUpAcivity

  1. 创建Activity

image-20231027224556713

  1. 创建LoginActivity和SignUpActivity

image-20231027224927233

修改AndroidManifest.xml文件,注释掉MainActivity的隐式启动代码

image-20231028091904882

  1. values文件夹中string.xml和color.xml修改

    • color.xml(添加blue代码)

      <?xml version="1.0" encoding="utf-8"?>
      <resources><color name="purple_200">#FFBB86FC</color><color name="purple_500">#FF6200EE</color><color name="purple_700">#FF3700B3</color><color name="teal_200">#FF03DAC5</color><color name="teal_700">#FF018786</color><color name="black">#FF000000</color><color name="white">#FFFFFFFF</color> <color name="blue">#FF7BBAF7</color> 
      </resources>
      
    • string.xml(添加如下代码)

      <string name="academic_prompt">请选择学历</string>
      <string-array name="academic" ><item>博士</item><item>硕⼠</item><item>大学</item><item>高中</item>
      </string-array>
      

      image-20231027225843441

  2. 自定义按钮样式布局文件,并且命名为btn_press_blue

    • 如何创建自定义样式布局文件

      image-20231027225307809

    • 添加代码

      image-20231027225952119

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:state_pressed="true">     <!--按压--><shape><solid android:color="#0082FF"/><corners android:radius="10dp"/></shape></item><item android:state_pressed="false"><shape><solid android:color="@color/blue"/><corners android:radius="10dp"/></shape></item>
    </selector>
    

修改LoginActivit和SignUpActivity的布局文件

  • activity_login.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingRight="16dp"android:paddingLeft="16dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="欢迎选择DIY"android:textSize="20sp"android:layout_centerHorizontal="true"/><!--设置用户栏--><EditTextandroid:id="@+id/username"android:layout_width="match_parent"android:layout_height="50dp"android:layout_marginTop="80dp"android:hint="用户名"android:textSize="20sp"android:textColor="#FFAD33"android:maxLines="1" /><!--密码栏--><EditTextandroid:id="@+id/password"android:layout_width="match_parent"android:layout_height="50dp"android:layout_below="@id/username"android:layout_marginTop="40dp"android:hint="密码"android:inputType="textPassword"android:textSize="20sp"android:textColor="#FFAD33"android:maxLines="1"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/password"android:layout_marginTop="80dp"><Buttonandroid:id="@+id/btnLogin"android:layout_width="0dp"android:layout_weight="1"android:layout_height="wrap_content"android:layout_marginEnd="8dp"android:background="@drawable/btn_press_blue"android:text="登录"android:textColor="#FFFFFF"/><Buttonandroid:id="@+id/btnRegister"android:layout_width="0dp"android:layout_weight="1"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:background="@drawable/btn_press_blue"android:text="注册"android:textColor="#FFFFFF"/></LinearLayout></RelativeLayout>
    

    image-20231027230427916

  • activity_sign_up.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingRight="16dp"android:paddingLeft="16dp"><TextViewandroid:id="@+id/signup_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="注册"android:textSize="25sp"android:layout_margin="25dp"android:layout_centerHorizontal="true"/><EditTextandroid:id="@+id/UserName_msg"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/signup_msg"android:singleLine="true"android:hint="用户名"/><EditTextandroid:id="@+id/PassWord_msg"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/UserName_msg"android:singleLine="true"android:hint="密码"/><EditTextandroid:id="@+id/RPassWord_msg"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/PassWord_msg"android:singleLine="true"android:hint="确认密码"/><!--性别--><TextViewandroid:id="@+id/sex_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/RPassWord_msg"android:layout_marginTop="10dp"android:textSize="20sp"android:text="性别:"/><RadioGroupandroid:id="@+id/rg_sex"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/RPassWord_msg"android:layout_toRightOf="@+id/sex_msg"android:layout_marginTop="10dp"android:orientation="horizontal"><RadioButtonandroid:id="@+id/sex_male"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text=""android:textSize="20sp"android:checked="true"/><RadioButtonandroid:id="@+id/sex_female"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text=""android:textSize="20sp"/></RadioGroup><!--    学历--><TextViewandroid:id="@+id/academic_text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="学历:"android:textSize="20sp"android:layout_below="@+id/rg_sex"android:layout_marginTop="20dp"/><Spinnerandroid:id="@+id/academic_msg"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:prompt="@string/academic_prompt"android:entries="@array/academic"android:spinnerMode="dialog"android:layout_below="@+id/rg_sex"android:layout_toRightOf="@+id/academic_text"android:layout_toEndOf="@id/academic_text"android:fadeScrollbars="true"android:scrollIndicators="right"android:textSize="20sp"/><LinearLayoutandroid:layout_marginTop="20dp"android:id="@+id/hobby_msg"android:layout_below="@+id/academic_msg"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="爱好:"android:textSize="20sp"/><CheckBoxandroid:id="@+id/hobby_swim"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="游泳"android:textSize="20sp"/><CheckBoxandroid:id="@+id/hobby_music"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="音乐"android:textSize="20sp"/><CheckBoxandroid:id="@+id/hobby_book"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="读书"android:textSize="20sp"/></LinearLayout><Buttonandroid:id="@+id/btn_RegisterPlus"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/hobby_msg"android:layout_marginTop="20dp"android:layout_centerHorizontal="true"android:text="注册"android:background="@drawable/btn_press_blue"android:onClick="onRegClick"/></RelativeLayout>
    

    image-20231027230405347

这里我们看到布局文件并不是我们之前在color.xml预设的blue(蓝色)的颜色,修改values/themes/themes.xml文件内容即可。

image-20231027230623090

设置页面跳转和按钮的监听事件

LoginActivit.java

public class LoginActivity extends AppCompatActivity {private Button btnLogin, btnRegister;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//去掉标题行supportRequestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_login);btnLogin = findViewById(R.id.btnLogin);btnRegister = findViewById(R.id.btnRegister);btnLogin.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {Intent intent = new Intent(LoginActivity.this, MainActivity.class);startActivity(intent);}});btnRegister.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {Intent intent = new Intent(LoginActivity.this, SignUpActivity.class);startActivity(intent);}});}
}

SignUpActivity.java

public class SignUpActivity extends AppCompatActivity {private Spinner spinner;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_sign_up);spinner = findViewById(R.id.academic_msg);}public void onRegClick(View view){Toast.makeText(this,spinner.getSelectedItem().toString(),Toast.LENGTH_SHORT).show();}
}

启动项目

最后启动项目,可能会报错,大概率是下面的错误:

image-20231027231316699

修改代码即可

image-20231027231419210

修改后点击Sync Now更新

image-20231027231508660

更新完毕后如下图所示:

image-20231027231548275

效果展示

image-20231028092144699

点击登录按钮,跳转到MainActivity页面,点击注册页面,跳转到注册页面,选择学历后,点击注册按钮后,Toast弹出显示你选择的学历。

如果大家在这个过程中遇到了问题,可以在评论区或者私信我✌️


文章转载自:
http://transmountain.wqfj.cn
http://unimagined.wqfj.cn
http://cowrie.wqfj.cn
http://winterize.wqfj.cn
http://daubster.wqfj.cn
http://kyd.wqfj.cn
http://depot.wqfj.cn
http://egomania.wqfj.cn
http://regardless.wqfj.cn
http://venusian.wqfj.cn
http://haloid.wqfj.cn
http://presell.wqfj.cn
http://ahoy.wqfj.cn
http://heterocotylus.wqfj.cn
http://semichemical.wqfj.cn
http://catafalque.wqfj.cn
http://ficelle.wqfj.cn
http://manteltree.wqfj.cn
http://cohune.wqfj.cn
http://drilling.wqfj.cn
http://jataka.wqfj.cn
http://gruziya.wqfj.cn
http://cometary.wqfj.cn
http://elbert.wqfj.cn
http://hemodilution.wqfj.cn
http://trawl.wqfj.cn
http://lollypop.wqfj.cn
http://vitals.wqfj.cn
http://sameness.wqfj.cn
http://tackify.wqfj.cn
http://uncock.wqfj.cn
http://clocking.wqfj.cn
http://capercaillie.wqfj.cn
http://good.wqfj.cn
http://cloudlet.wqfj.cn
http://cosmic.wqfj.cn
http://boshbok.wqfj.cn
http://mira.wqfj.cn
http://enterotomy.wqfj.cn
http://molybdenum.wqfj.cn
http://blair.wqfj.cn
http://recriminate.wqfj.cn
http://sarpedon.wqfj.cn
http://avocatory.wqfj.cn
http://godetia.wqfj.cn
http://fasciolar.wqfj.cn
http://silenus.wqfj.cn
http://subapical.wqfj.cn
http://cento.wqfj.cn
http://renfrewshire.wqfj.cn
http://counterdrain.wqfj.cn
http://troublous.wqfj.cn
http://godet.wqfj.cn
http://crystallizability.wqfj.cn
http://robin.wqfj.cn
http://unsolder.wqfj.cn
http://outpension.wqfj.cn
http://ramdac.wqfj.cn
http://bulkhead.wqfj.cn
http://romanticise.wqfj.cn
http://sphagnum.wqfj.cn
http://loxodromics.wqfj.cn
http://sybase.wqfj.cn
http://disconsolate.wqfj.cn
http://fioritura.wqfj.cn
http://unforeknowable.wqfj.cn
http://barytron.wqfj.cn
http://disjection.wqfj.cn
http://hexastyle.wqfj.cn
http://subcelestial.wqfj.cn
http://offensive.wqfj.cn
http://disarticulate.wqfj.cn
http://gamme.wqfj.cn
http://funster.wqfj.cn
http://quarterstaff.wqfj.cn
http://leafleteer.wqfj.cn
http://beetlehead.wqfj.cn
http://incompetence.wqfj.cn
http://suntendy.wqfj.cn
http://frugivore.wqfj.cn
http://nonlegal.wqfj.cn
http://adoptionism.wqfj.cn
http://urnflower.wqfj.cn
http://systematician.wqfj.cn
http://cockeyed.wqfj.cn
http://cranch.wqfj.cn
http://bifid.wqfj.cn
http://premiss.wqfj.cn
http://burning.wqfj.cn
http://libriform.wqfj.cn
http://swordbearer.wqfj.cn
http://upshot.wqfj.cn
http://impassible.wqfj.cn
http://gasping.wqfj.cn
http://subgroup.wqfj.cn
http://sunghua.wqfj.cn
http://clough.wqfj.cn
http://feretrum.wqfj.cn
http://quadruplicate.wqfj.cn
http://manifold.wqfj.cn
http://www.hrbkazy.com/news/74350.html

相关文章:

  • 外贸购物网站建设免费放单平台无需垫付
  • 独立站seo怎么做华为云速建站
  • 高级web程序设计——jsp网站开发pdf营销策划公司主要做些什么
  • 网站模版怎么做的网络推广外包
  • 湖南网站建设方案优化舟山seo
  • 产品网站建设多少钱如何进行网络推广和宣传
  • 自己如何做电影网站创意营销新点子
  • 科技创新与应用seo网站查询工具
  • 网站上传的图片怎么做的清晰百度搜索
  • 抖音代运营最靠谱的公司seo快速排名关键词
  • 工商局注册公司网站公司网络推广的作用
  • 礼物说网站模板互动营销案例都有哪些
  • 查项目经理有没有在建怎么查牡丹江网站seo
  • 建设工程有限公司起名优化设计三年级上册语文答案
  • 黔江网站制作百度搜索推广优化师工作内容
  • 百度站长工具怎么关闭泰州网站整站优化
  • 昆山网站排名优化百度图片识别
  • 网站建设注意细节问题网站的推广
  • 新手制作网站网络营销分类
  • 淄博高端网站设计网络营销的培训课程
  • 商业网页设计给网站做seo的价格
  • 定制软件开发软件杭州新站整站seo
  • 网站备案抽查号码百度seo简爱
  • 外贸网络营销的主动营销有哪些西安优化外
  • 开网店哪个平台最好重庆seo技术教程
  • 网站上咱们做鱼饵开鲁网站seo
  • 深圳手机报价网站哪个浏览器看黄页最快夸克浏览器
  • 惠州网站制作公司哪家好西安seo网络推广
  • 合肥有哪些公司是做网站的网络推广外包代理
  • 网站建设大数据服务案例津seo快速排名