package com.example.register.activity;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

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

import com.example.register.CategoryActivity;
import com.example.register.R;

public class userActivity extends AppCompatActivity implements View.OnClickListener{
    EditText username,sex,city;
    LinearLayout search;

    Button exit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user);
        init();
        params();
    }

    /**
     * 初始化组件
     */
    public void init(){
        username = findViewById(R.id.login_name);
        sex = findViewById(R.id.reg_sex);
        city = findViewById(R.id.reg_address);

        search = findViewById(R.id.user_searchProduct);
        search.setOnClickListener(this);
//        search.setOnClickListener(view -> {
//            Intent intent1 =new Intent();
//            Intent.setClass(this,CategoryActivity.class);
//            startActivity(intent1);
//        });

        exit=findViewById(R.id.exit);
        exit.setOnClickListener(view -> {
            Intent intent = new Intent();
            intent.setClass(this, loginActivity.class);
            startActivity(intent);
        });
    }


//    @Override
//    public void onClick(View v) {
//        switch (v.getId()) {
//            case R.id.user_searchProduct:
//                Intent intent1 = new Intent(this, CategoryActivity.class);
//                startActivity(intent1);
//                break;
//        }
//    }



    /**
     * 接收参数
     */

    public void params(){
        //接收结果
        Bundle bundle = this.getIntent().getExtras();
        String usernameStr =bundle.getString("username");
        String passwordStr =bundle.getString("password");
        String sexStr =bundle.getString("sex");
        String cityStr =bundle.getString("city");
        username.setText("用户名： " + usernameStr);
        sex.setText("性别： " + sexStr);
        city.setText("地址： " + cityStr);
    }

    @Override
    public void onClick(@NonNull View v) {
        switch (v.getId()) {
            case R.id.user_searchProduct:
                Intent intent1 = new Intent(userActivity.this, CategoryActivity.class);
                startActivity(intent1);
                break;
        }
    }
    }
