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();
    }
  • 相关阅读:
    Silverlight 手鼓达人-仿太鼓达人 开源
    友盟推送 .NET (C#) 服务端 SDK rest api 调用库
    信鸽推送 .NET (C#) 服务端 SDK rest api 调用库(v1.2)
    MachineKey 操作 之 应用集群中SSO应用生成MachineKey
    MachineKey 操作 之 获取 MachineKey
    Visual Studio (VS IDE) 你必须知道的功能和技巧
    正则表达式 匹配(获取) 所有表名
    程序员何苦为难程序员!
    学习资料集合
    转载:centos7 yum安装php7.3(解决yum安装apache关联不了PHP的问题)
  • 原文地址:https://www.cnblogs.com/chenghaixiang/p/14913844.html
Copyright © 2011-2022 走看看