用android studio写一个简单的记单词?????App

  一个贼贼简单的APP,按照前端来说,就只是实现了几个页面跳转和点击事件,数据库链接都没用到。就这么几个简单的页面和跳转,各位见笑了。

看一下效果吧:

页面设计(activity_main):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:padding="10dp"
    android:background="@mipmap/pp1"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/tv1"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:text="我爱安卓"
        android:textColor="#000000 "
        android:textSize="18sp"
        android:layout_gravity="center"
        android:layout_marginTop="160dp"
         />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="欢迎登入,hello"
        android:textColor="#FF5722"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

   <EditText
       android:id="@+id/et_1"
       android:layout_width="match_parent"
       android:layout_height="50dp"
       android:textSize="16sp"
       android:textColor="@color/colorBlack"

      android:hint="用户名:"
       android:maxLines="1"
       android:padding="5dp"
       android:layout_marginTop="8dp"
       android:background="@drawable/bb_username"
       />

    <EditText
        android:id="@+id/et_2"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:textSize="16sp"
        android:textColor="@color/colorBlack"
        android:hint="密码:"
        android:maxLines="1"
        android:padding="5dp"
        android:inputType="textPassword"
        android:layout_marginTop="6dp"
        android:background="@drawable/bb_username"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp"
>

        <Button
            android:id="@+id/btn_login"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_weight="1"
            android:background="@drawable/bbn_1left"
            android:textColor="#000000"
            android:text="登入" />

        <Button
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:text="注册"
            android:layout_marginLeft="2dp"
            android:background="@drawable/bbn_1right"
            android:textColor="#000000"
            />

    </LinearLayout>

</LinearLayout>

java(MainActivity):

package com.example.jdcapp;

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;

import com.example.jdcapp.util.ToastUtil;


public class MainActivity extends  AppCompatActivity implements View.OnClickListener {
    //声明控件
    private Button mBtnLogin;
    private EditText mEtUser;
    private  EditText mEtPassword;

    @Override
    protected void onCreate(Bundle savedInstanceState){

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //找到控件
        mBtnLogin = findViewById(R.id.btn_login);
        mEtUser = findViewById(R.id.et_1);
        mEtPassword = findViewById(R.id.et_2);

//    //实现跳转
//    mBtnLogin.setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//            Intent intent =null;
//            intent = new Intent(MainActivity.this,SlideActivity.class);
//            startActivity(intent);
//        }
//    });
        mBtnLogin.setOnClickListener(this);
    }
    public void onClick(View v){
        //需要获取用户名和密码
        String username = mEtUser.getText().toString();
        String password = mEtPassword.getText().toString();
        //弹出的内容设置
        String ok = "登入成功";
        String fail = "密码或者账号有误,请重新输入";

        Intent intent = null ;
        //假设正确的账号是ttk,密码是 123456
        if(username.equals("ttj")&&password.equals("123456")){
            //封装好的类
            ToastUtil.showMsg(MainActivity.this,ok);
            //如果正确的话进行跳转
            intent = new Intent(MainActivity.this,SlideActivity.class);
            startActivity(intent);
        }
        else{
//         Toast toastCenter = Toast.makeText(getApplicationContext(),fail,Toast.LENGTH_SHORT);
//         toastCenter.setGravity(Gravity.CENTER,0,0);
//         toastCenter.show();
            ToastUtil.showMsg(MainActivity.this,fail);

        }

    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }
}

用户名和密码是写死的: 用户名:ttj  密码:123456  

 

 

页面设计(activity_slide):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:padding="10dp"
    android:background="@mipmap/tp2"
    tools:context=".SlideActivity">


    <TextView
        android:id="@+id/vt_gunc_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="主界面"
        android:textSize="30sp"
        android:gravity="center"
        />


    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="选择学习类型"
        android:gravity="center"
        android:layout_marginTop="150dp"
        android:textColor="#000000"/>

    <Button
        android:id="@+id/xfw_1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="安卓发展史"
        android:gravity="center"
        android:layout_marginLeft="10dp"
        android:background="@drawable/bb_username"
        android:textColor="#000000"
        />

    <Button
        android:id="@+id/xfw_2"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="安卓语法"
        android:gravity="center"
        android:layout_marginLeft="10dp"
        android:background="@drawable/bb_username"
        android:textColor="#000000"
        />

    <Button
        android:id="@+id/xfw_3"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="安卓基本常识"
        android:gravity="center"
        android:layout_marginLeft="10dp"
        android:background="@drawable/bb_username"
        android:textColor="#000000"
        />

    <Button
        android:id="@+id/xfw_4"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="安卓小测试"
        android:gravity="center"
        android:layout_marginLeft="10dp"
        android:background="@drawable/bb_username"
        android:textColor="#000000"
        />






</LinearLayout>

 java(SlideActivity):

package com.example.jdcapp;

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

import androidx.appcompat.app.AppCompatActivity;

public class SlideActivity extends AppCompatActivity {
    //声明控件
    private  Button mBhistory;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slide);
        //找到控件
        mBhistory = findViewById(R.id.xfw_1);

        //实现跳转
        mBhistory.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = null ;
                intent = new Intent(SlideActivity.this,function1Activity.class);
                startActivity(intent);

            }
        });
    }

}


 

页面设计(activity_function1.xml):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:padding="10dp"
    tools:context=".function1Activity">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:text="下面是安卓的发展历史"
        android:textSize="30sp"
        android:gravity="center"
        android:textColor="#DF1157"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="320dp"
        android:text="  2003年10月,Andy Rubin等人创建Android公司,并组建Android团队。2005年8月17日,Google低调收购了成立仅22个月的高科技企业Android及其团队。安迪鲁宾成为Google公司工程部副总裁,继续负责Android项目。

2007年11月5日,谷歌公司正式向外界展示了这款名为Android的操作系统。直到2011年1月,谷歌称每日的Android设备新用户数量达到了30万部,到2011年7月,这个数字增长到55万部,而Android系统设备的用户总数达到了1.35亿,Android系统已经成为智能手机领域占有量最高的系统。"
        android:textSize="20sp"
        android:textColor="#000000"
        />

 <TextView
     android:layout_width="match_parent"
     android:layout_height="40dp"
     android:text="小练习:下面哪个是Android标志呢????"
     android:textSize="20sp"
     android:padding="5dp"
     android:textColor="#068006"
     />

   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       >

    <ImageView
        android:id="@+id/iv_an"
        android:layout_width="100dp"
        android:layout_height="70dp"
        android:src="@mipmap/tp9"
        />


        <ImageView
            android:id="@+id/iv_an2"
            android:layout_width="90dp"
            android:layout_height="70dp"
            android:src="@mipmap/tp3"
            />

       <ImageView
           android:layout_width="90dp"
           android:layout_height="70dp"
           android:src="@mipmap/tp5"
           />
       <ImageView
           android:layout_width="90dp"
           android:layout_height="70dp"
           android:src="@mipmap/tp8"
           />

   </LinearLayout>

</LinearLayout>

 java(function1Activity):

package com.example.jdcapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class function1Activity extends AppCompatActivity {
    private ImageView Iman;
    private ImageView Iman2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_function1);

        Iman = findViewById(R.id.iv_an);
        Iman2 = findViewById(R.id.iv_an2);

        Iman.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =null;
                intent = new Intent(function1Activity.this, com.example.jdcapp.function11Activity.class);
                startActivity(intent);
            }
        });

        Iman2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent =null;
                intent = new Intent(function1Activity.this,funnn.class);
                startActivity(intent);
            }
        });

}
}

 

页面设计(activity_function11.xml):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    android:background="@mipmap/pp1"
    tools:context=".function11Activity">


    <TextView
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:text=" 恭喜答对了!!!"
        android:textSize="30sp"
        android:gravity="center"
        android:textColor="#DF1157"
        android:layout_marginTop="200dp"
        />

    <ImageView
        android:id="@+id/iv_apple"
        android:layout_width="90dp"
        android:layout_height="70dp"
        android:src="@mipmap/tp9"
        />


</LinearLayout>

 java(function11Activity ):

package com.example.jdcapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class function11Activity extends AppCompatActivity {
    private ImageView Iman;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_function11);

       // Iman = findViewById(R.id.iv_apple);

//        Iman.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent =null;
//                intent = new Intent(function11Activity.this,funnn.class);
//                startActivity(intent);
//            }
//        });
    }
}

别忘了配置AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.jdcapp">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.JDCApp"
        tools:targetApi="31">

        <activity android:name=".function11Activity" />
        <activity android:name=".function1Activity" />
        <activity android:name=".SlideActivity" />
        <activity android:name=".funnn" />
        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

最后就是用到的样式和目录结构:

bb_username.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
    android:width="2dp"
    android:color="@color/colorBlack"
    />
<corners
    android:radius="50dp"

    />

    <solid
        android:color="#00000000"
        />

</shape>

bbn_1left.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
    android:width="2dp"
    android:color="@color/colorBlack"
    />
<corners
    android:topLeftRadius="150dp"
    android:bottomLeftRadius="150dp"
    />

    <solid
        android:color="#00000000"
        />
</shape>

bbn_1right.xml 

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
    android:width="2dp"
    android:color="@color/colorBlack"
    />
<corners
    android:topRightRadius="5dp"
    android:bottomRightRadius="5dp"
    />

    <solid
        android:color="#00000000"
        />

</shape>

  • 11
    点赞
  • 62
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

懒鱼七忆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值