登录注册购物车有订单

activity_main


<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"
    tools:context="bwie.com.lianxiyuekao.MainActivity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        >

        <ImageView
            android:layout_width="160dp"
            android:layout_height="160dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@drawable/tao" />
    </RelativeLayout>
    <EditText
        android:id="@+id/phone"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="手机号"/>
    <EditText
        android:id="@+id/password"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"/>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        >
        <TextView
            android:id="@+id/wang"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="忘记密码"
            android:layout_marginLeft="10dp"
            android:gravity="center_vertical"/>

        <TextView
            android:id="@+id/reg"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignParentEnd="true"
            android:layout_alignParentTop="true"
            android:gravity="center_vertical"
            android:layout_marginRight="10dp"
            android:text="新用户注册" />
    </RelativeLayout>
    <Button
        android:id="@+id/login"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="登录"/>
</LinearLayout>
MainActivity


public class MainActivity extends AppCompatActivity implements LoginPresenter.MainPresenter{
    private EditText phone,password;
    private TextView reg,wang;
    Button login;
    private LoginPresenter loginPresenter;
    MD5Helper md5Helper;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        phone = findViewById(R.id.phone);
        password =findViewById(R.id.password);
        login =findViewById(R.id.login);
        reg =findViewById(R.id.reg);
        wang=findViewById(R.id.wang);
        wang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "你咋这么笨呢,密码都忘了", Toast.LENGTH_SHORT).show();
            }
        });
        loginPresenter = new LoginPresenter(this);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String md5 = MD5Helper.getMD5(password.getText().toString());
                loginPresenter.loginClick("login", phone.getText().toString(),md5);
            }
        });
        reg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loginPresenter.regClick();
            }
        });
    }
    //登录
    @Override
    public void lClick(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
        Intent intent=new Intent(this,LieActivity.class);
        startActivity(intent);
    }

    @Override
    public void rClick() {
        startActivity(new Intent(MainActivity.this, ZhuActivity.class));
    }
}
activity_zhu

<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"
    tools:context="bwie.com.lianxiyuekao.ZhuActivity">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="40dp">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="注册"
        android:layout_marginTop="5dp"
        android:textSize="30sp"
        android:gravity="center_horizontal"/>
    <ImageView
        android:id="@+id/iv_fan"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:background="@drawable/fan"
        />
</RelativeLayout>
    <EditText
        android:id="@+id/phone"
        android:layout_marginTop="30dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="手机号"/>
    <EditText
        android:id="@+id/password"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"/>
    <EditText
        android:id="@+id/password1"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="再次输入密码"/>
    <EditText
        android:id="@+id/youxiang"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="填写邮箱"/>
    <Button
        android:id="@+id/btn_zhu"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:text="登录"/>
</LinearLayout>
public class ZhuActivity extends AppCompatActivity implements LoginPresenter.MainPresenter{
    private EditText rphone,rpassword;
    private Button lreg;
    private ImageView iv_fan;
    private LoginPresenter loginPresenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhu);
        rphone = (EditText) findViewById(R.id.phone);
        rpassword = (EditText) findViewById(R.id.password);
        lreg = (Button) findViewById(R.id.btn_zhu);
        iv_fan=findViewById(R.id.iv_fan);
        loginPresenter = new LoginPresenter(this);
        iv_fan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(ZhuActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });
        lreg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loginPresenter.loginClick("reg", rphone.getText().toString(), rpassword.getText().toString());
            }
        });
    }
    @Override
    public void lClick(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void rClick() {

    }

}

activity_lie

<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"
    tools:context="bwie.com.lianxiyuekao.LieActivity">
    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</LinearLayout>

public class LieActivity extends AppCompatActivity implements IRecyView {
    private RecyclerView xrv;
    private RecyPresenter presenter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lie);
        initView();
        presenter = new RecyPresenter(this);
        presenter.showRecy();
    }
    private void initView() {
        xrv =findViewById(R.id.rv);
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        xrv.setLayoutManager(manager);
    }
    @Override
    public void showRecy(final InfoDatas infoDatas) {
        MyRecyAdapter myRecyAdapter = new MyRecyAdapter(this, infoDatas);
        xrv.setAdapter(myRecyAdapter);

        myRecyAdapter.setClick(new MyRecyAdapter.Click() {
            @Override
            public void itemclick(int position) {
                Toast.makeText(LieActivity.this, position+"", Toast.LENGTH_SHORT).show();
                Intent intent=new Intent(LieActivity.this,XiangActivity.class);
                intent.putExtra("pid",position+"");
                startActivity(intent);
            }
        });
    }
}

MyRecyAdapter

public class MyRecyAdapter extends RecyclerView.Adapter<MyRecyAdapter.MyViewHolder> {
    Context context;
    InfoDatas infoDatas;
    private View view;

    public MyRecyAdapter(Context context, InfoDatas infoDatas) {
        this.context = context;
        this.infoDatas = infoDatas;
    }

    @Override
    public MyRecyAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        view = View.inflate(context, R.layout.list_item,null);

        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyRecyAdapter.MyViewHolder holder, final int position) {
        holder.tv1.setText(infoDatas.getData().get(position).getTitle());
        holder.tv2.setText(infoDatas.getData().get(position).getPrice()+"");
        String[] split = infoDatas.getData().get(position).getImages().split("\\|");
        Glide.with(context).load(split[1]).into(holder.iv);
        //每个条目的点击事件
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                click.itemclick(infoDatas.getData().get(position).getPid());
            }
        });
    }

    @Override
    public int getItemCount() {
        return infoDatas.getData().size();
    }


    public class MyViewHolder extends RecyclerView.ViewHolder{
        ImageView iv;
        TextView tv1,tv2;
        public MyViewHolder(View itemView) {
            super(itemView);
            iv=itemView.findViewById(R.id.iv);
            tv1=itemView.findViewById(R.id.tv1);
            tv2=itemView.findViewById(R.id.tv2);
        }
    }
    //点击事件---------------------------------
    private Click click;
    public void setClick(Click click){
        this.click=click;
    }
    public interface Click{
        void itemclick(int position);
    }
    //-----------------------------------------
}



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值