public class Yhdlzc extends AppCompatActivity implements View.OnClickListener{ private EditText ed_mima; private EditText ed_sjh; private Button but_dl; private Button but_zc; private String mima; private String sjh; private String num="[1][358]\\d{9}"; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_yhdlzc); ed_sjh = (EditText) findViewById(R.id.edshoujihao); ed_mima = (EditText) findViewById(R.id.edmima); but_dl= (Button) findViewById(R.id.butdl); but_zc= (Button) findViewById(R.id.butzc); but_dl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mima = ed_mima.getText().toString().trim(); sjh = ed_sjh.getText().toString().trim(); boolean flag=checkData(mima,sjh); if(flag){ register(mima,sjh); }else{ Toast.makeText(Yhdlzc.this,"手机不合法",Toast.LENGTH_LONG).show(); } } }); but_zc.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent=new Intent(Yhdlzc.this, Zhuce.class); startActivity(intent); } }); } private void register(String mima, String sjh) { final RequestParams params=new RequestParams("http://120.27.23.105/user/login"); params.addQueryStringParameter("mobile",sjh); params.addQueryStringParameter("password",mima); x.http().get(params, new Callback.CommonCallback<String>() { @Override public void onSuccess(String result) { Gson gson = new Gson(); LoginBean bean = gson.fromJson(result, LoginBean.class); Toast.makeText(Yhdlzc.this,bean.getMsg(),Toast.LENGTH_SHORT).show(); if(bean.getCode().equals("0")){ Toast.makeText(Yhdlzc.this,"好了",Toast.LENGTH_SHORT).show(); } } @Override public void onError(Throwable ex, boolean isOnCallback) { } @Override public void onCancelled(CancelledException cex) { } @Override public void onFinished() { } }); } private boolean checkData(String mima, String sjh) { if(TextUtils.isEmpty(sjh)||TextUtils.isEmpty(mima)){ Toast.makeText(Yhdlzc.this,"手机号和密码不能为空",Toast.LENGTH_LONG).show(); return false; }else if(mima.length()<6){ Toast.makeText(Yhdlzc.this,"密码不能小于6位",Toast.LENGTH_LONG).show(); return false; }else{ return sjh.matches(num); } } @Override public void onClick(View view) { } }
注册 public class Zhuce extends AppCompatActivity { private String sjh; private String mm; private Button butzhuce; private EditText zcsjh; private EditText zcmima; private String num="[1][358]\\d{9}"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_zhuce); butzhuce = (Button) findViewById(R.id.butzhuce); zcsjh = (EditText) findViewById(R.id.edzhucesjh); zcmima = (EditText) findViewById(R.id.edzhucemima); sjh= zcsjh.getText().toString(); mm= zcmima.getText().toString(); butzhuce.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sjh= zcsjh.getText().toString(); mm= zcmima.getText().toString(); boolean a=checkData(sjh,mm); if(a==true){ Toast.makeText(Zhuce.this,"可以",Toast.LENGTH_LONG).show(); regfster(sjh,mm); }else{ Toast.makeText(Zhuce.this,"手机不合法",Toast.LENGTH_LONG).show(); } } }); } private void regfster(String sjh, String mm) { RequestParams params = new RequestParams("http://120.27.23.105/user/reg"); params.addBodyParameter("mobile",sjh); params.addBodyParameter("password",mm); x.http().get(params, new Callback.CommonCallback<String>() { @Override public void onSuccess(String result) { Gson gson = new Gson(); RegistBean bean = gson.fromJson(result, RegistBean.class); Toast.makeText(Zhuce.this,bean.getMsg(),Toast.LENGTH_SHORT).show(); if(bean.getCode().equals("0")){ finish(); } } @Override public void onError(Throwable ex, boolean isOnCallback) { } @Override public void onCancelled(CancelledException cex) { } @Override public void onFinished() { } }); } private boolean checkData(String sjh, String mm) { if(TextUtils.isEmpty(sjh)||TextUtils.isEmpty(mm)){ Toast.makeText(this,"手机号和密码不能为空",Toast.LENGTH_LONG).show(); return false; } else if(mm.length()<6){ Toast.makeText(this,"密码不能小于6位",Toast.LENGTH_LONG).show(); return false; }else { return sjh.matches(num); } } }
webview public class Xiangqing extends AppCompatActivity { private WebView xqweb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_xiangqing); Intent intent = getIntent(); String s = intent.getStringExtra("name"); xqweb = (WebView) findViewById(R.id.xq_web); // 缩放至屏幕的大小 xqweb.getSettings().setLoadWithOverviewMode(true); //webVew去加载网页 xqweb.loadUrl(s); //设置用自己的浏览器打开 xqweb.setWebViewClient(new MyWebViewClient()); } class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return super.shouldOverrideUrlLoading(view, url); } } }
<WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/xq_web"></WebView>
登录注册+webview
最新推荐文章于 2021-12-24 16:59:09 发布