zoukankan      html  css  js  c++  java
  • 团队冲刺6

    1.今天完成注册页面信息验证并提交到服务器

    private Button button_zhuce;
    private OkHttpClient okHttpClient=new OkHttpClient();
    private Handler handler=new Handler(){
    @Override
    public void handleMessage(@NonNull Message msg) {
    super.handleMessage(msg);
    Intent intent = new Intent();
    button_zhuce = (Button) findViewById(R.id.btn_register_button);
    String panding= (String) msg.obj;
    Log.e("sss",panding);
    String zhuce="注册成功";
    panding=panding.trim();
    if(zhuce.equals(panding)){
    Log.e("pp","1");
    Toast.makeText(RegisterActivity.this,"注册成功",Toast.LENGTH_SHORT).show();
    button_zhuce.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

    intent.setClass(RegisterActivity.this, MainActivity.class);//this前面为当前activty名称,class前面为要跳转到得activity名称
    startActivity(intent);
    }
    });
    }
    else{
    Log.e("pp","2");
    Toast.makeText(RegisterActivity.this,panding,Toast.LENGTH_SHORT).show();
    }
    }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register_tream);
    initview();
    }

    private void initview() {
    account=findViewById(R.id.register_name);
    password=findViewById(R.id.register_password);
    password_again=findViewById(R.id.register_password_agin);
    email=findViewById(R.id.register_mail);
    register=findViewById(R.id.btn_register_button);
    register.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
    if(password.getText().toString().equals(password_again.getText().toString())){
    account2=account.getText().toString();
    password2=password.getText().toString();
    email2=email.getText().toString();
    get();
    }
    else{
    Toast.makeText(this,"密码不一致",Toast.LENGTH_SHORT).show();
    }
    }
    private void get(){
    new Thread(){
    @Override
    public void run() {
    super.run();
    String url="http://";
    try {
    String result=getData(url);
    Log.e("内容:",result);
    Message msg= Message.obtain();
    msg.obj=result;
    handler.sendMessage(msg);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }.start();
    }
    private String getData(String url) throws IOException {
    RequestBody responseBody=new FormBody.Builder()
    .add("account",account2)
    .add("password",password2)
    .add("email",email2)
    .build();
    Request request=new Request.Builder().post(responseBody).url(url).build();
    Response response=okHttpClient.newCall(request).execute();
    return response.body().string();
    }
  • 相关阅读:
    按分类统计商品总数的性能优化思考
    Flash/Flex学习笔记(52):使用TweenLite
    Flash/Flex学习笔记(36):自己动手实现一个滑块控件(JimmySilder)
    解决JQuery中的ready函数冲突
    Flash/Flex学习笔记(41):碰撞检测
    Flash/Flex学习笔记(34):AS3中的自定义事件
    如何改变AspNetPager当前页码的默认红色?
    Flash/Flex学习笔记(42):坐标旋转
    Flash/Flex学习笔记(39):弹性运动
    C#检测SqlServer中某张表是否存在
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14913844.html
Copyright © 2011-2022 走看看