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

简介: 用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>

相关文章
|
9月前
|
开发工具 Android开发 iOS开发
如何在Android Studio中配置Flutter环境?
如何在Android Studio中配置Flutter环境?
2134 61
|
8月前
|
Android开发 数据安全/隐私保护 开发者
Android自定义view之模仿登录界面文本输入框(华为云APP)
本文介绍了一款自定义输入框的实现,包含静态效果、hint值浮动动画及功能扩展。通过组合多个控件完成界面布局,使用TranslateAnimation与AlphaAnimation实现hint文字上下浮动效果,支持密码加密解密显示、去除键盘回车空格输入、光标定位等功能。代码基于Android平台,提供完整源码与attrs配置,方便复用与定制。希望对开发者有所帮助。
156 0
|
11月前
|
JavaScript 前端开发 Android开发
【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
413 13
【03】仿站技术之python技术,看完学会再也不用去购买收费工具了-修改整体页面做好安卓下载发给客户-并且开始提交网站公安备案-作为APP下载落地页文娱产品一定要备案-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
|
8月前
|
Android开发 Windows
Android studio 报错Connect to 127.0.0.1:8888 [/127.0.0.1] failed: Connection refused: connect(已解决)
这是一篇关于解决Android Studio报错“Connect to 127.0.0.1:8888 failed: Connection refused”的文章。问题通常因系统代理设置被Android Studio自动保存导致。解决方法是找到系统中Android Studio使用的gradle.properties文件(位于Windows的C:\Users\你的电脑用户名\.gradle或Mac的/Users/.{你的用户目录}/.gradle),删除或注释掉多余的代理配置后保存并重新Sync项目。希望此经验能帮助快速解决同类问题!
1333 36
|
6月前
|
存储 Android开发 数据安全/隐私保护
Thanox安卓系统增加工具下载,管理、阻止、限制后台每个APP运行情况
Thanox是一款Android系统管理工具,专注于权限、后台启动及运行管理。支持应用冻结、系统优化、UI自定义和模块管理,基于Xposed框架开发,安全可靠且开源免费,兼容Android 6.0及以上版本。
721 4
|
8月前
|
Java Android开发
Android studio中build.gradle文件简单介绍
本文解析了Android项目中build.gradle文件的作用,包括jcenter仓库配置、模块类型定义、包名设置及依赖管理,涵盖本地、库和远程依赖的区别。
758 19
|
9月前
|
数据采集 JSON 网络安全
移动端数据抓取:Android App的TLS流量解密方案
本文介绍了一种通过TLS流量解密技术抓取知乎App热榜数据的方法。利用Charles Proxy解密HTTPS流量,分析App与服务器通信内容;结合Python Requests库模拟请求,配置特定请求头以绕过反爬机制。同时使用代理IP隐藏真实IP地址,确保抓取稳定。最终成功提取热榜标题、内容简介、链接等信息,为分析热点话题和用户趋势提供数据支持。此方法也可应用于其他Android App的数据采集,但需注意选择可靠的代理服务。
406 11
移动端数据抓取:Android App的TLS流量解密方案
|
11月前
|
前端开发 Java 编译器
当flutter react native 等混开框架-并且用vscode-idea等编译器无法打包apk,打包安卓不成功怎么办-直接用android studio如何打包安卓apk -重要-优雅草卓伊凡
当flutter react native 等混开框架-并且用vscode-idea等编译器无法打包apk,打包安卓不成功怎么办-直接用android studio如何打包安卓apk -重要-优雅草卓伊凡
346 36
当flutter react native 等混开框架-并且用vscode-idea等编译器无法打包apk,打包安卓不成功怎么办-直接用android studio如何打包安卓apk -重要-优雅草卓伊凡
|
11月前
|
前端开发 Java Shell
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
783 20
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
|
11月前
|
JavaScript 搜索推荐 Android开发
【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡
443 8
【01】仿站技术之python技术,看完学会再也不用去购买收费工具了-用python扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-客户的麻将软件需要下载落地页并且要做搜索引擎推广-本文用python语言快速开发爬取落地页下载-优雅草卓伊凡

热门文章

最新文章