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

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

看一下效果吧:

用android studio写一个简单的记单词?????App_第1张图片

页面设计(activity_main):




    

    

   

    

    

        

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  

 用android studio写一个简单的记单词?????App_第2张图片

 用android studio写一个简单的记单词?????App_第3张图片

页面设计(activity_slide):





    


    

    

 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);

            }
        });
    }

}


 用android studio写一个简单的记单词?????App_第4张图片

页面设计(activity_function1.xml):





    

    

 

   

    


        

       
       

   

 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);
            }
        });

}
}

 用android studio写一个简单的记单词?????App_第5张图片

页面设计(activity_function11.xml):





    

    


 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




    

        
        
        
        
        
            
                

                
            
        
    

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

bb_username.xml






    

bbn_1left.xml






    

bbn_1right.xml 






    

用android studio写一个简单的记单词?????App_第6张图片

你可能感兴趣的:(android)