Android music player (2) login registration interface

This is a simple music player project I made in my sophomore year last year: it was written as much as possible to imitate Kugou Music, and the specific functions are as follows:

1: Startup animation: Click to run the program and a two-second video will appear, similar to the startup animation of Kugou Music, very impressive!

2: Login registration interface: Enter the account number and password to check the information to log in!

3: Carousel: Exactly the same as Kugou Music, there is an automatic cycle carousel above the main interface, click on each picture information of the carousel to enter the corresponding specific service, very extra points!

4: The turntable of the music record, the progress bar of the song synchronization, and the pause/play/continue/switching of the music!

5: Music search is realized!

6: Play the video column!

7; The layout of the personal information interface is realized, such as feedback, rating, more, gender age nickname, collection, etc.!

The login and registration interface code is as follows:

package com.ypc.xiaoxiongmusic;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View.OnClickListener;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
public class LoginActivity extends AppCompatActivity{
    Button button;
    EditText edit1,edit2;
    CheckBox checkbox;
    ProgressBar bar;
    SharedPreferences pref;
    SharedPreferences.Editor editor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        button=(Button) findViewById(R.id.login_button);
        edit1=(EditText) findViewById(R.id.input1);
        edit2=(EditText) findViewById(R.id.input2);
        checkbox=(CheckBox) findViewById(R.id.remember_button);
        bar=(ProgressBar) findViewById(R.id.progress);
        pref= PreferenceManager.getDefaultSharedPreferences(this);
        boolean isRemember=pref.getBoolean("rem",false); //Used to assign whether to save the password 
                if(account.equals("zxr") && password.equals("xbt")) {
        if(isRemember) {
//将账号和密码设置到文本框中
            String account=pref.getString("account","");
            String password=pref.getString("password","");
            edit1.setText(account);
            edit2.setText(password);
            checkbox.setChecked(true);
        }
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                String account=edit1.getText().toString();
                String password=edit2.getText().toString();
                    editor = pref.edit();
                    if(checkbox.isChecked()) {
                        editor.putBoolean("rem",true); 
                        editor.putString("account",account); 
                        editor.putString("password",password); 
                    } 
                    else { 
                        editor.clear(); 
                    } 
                    editor.commit(); AlertDialog.Builder 
                    builder =new AlertDialog.Builder(LoginActivity.this); 
                    builder.setTitle("XiaoXiongMusic"); 
                    builder.setMessage("This APP is dedicated to bringing selected music services to users. All music in this software is authorized by me. It is strictly forbidden for users to use music, video and other resources in the APP to make illegal profits. Users must abide by the software agreement, and the final interpretation right belongs to DY.memory!"); 
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
    @OverrideOnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_HOME);
        startActivity(intent);
        System.exit(0);
    }
});
builder.setPositiveButton("agree", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        Intent intent=new Intent(LoginActivity.this,MainInterfaceActivity.class);
                    startActivity(intent);
    }
});
           builder.create().show();
                }
                else{
                    Toast.makeText(LoginActivity.this,"Account or username error",Toast.LENGTH_SHORT).show(); 
                } 
            } 
        }); 
    } 
}

The screenshot of the effect is as follows:

 

 

Guess you like

Origin blog.csdn.net/Abtxr/article/details/126839005