本文介绍了如何在edittext上验证IP以完成此操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void checkIP(String Value)
{
Pattern pattern = Pattern.compile("[0-255].[0-255].[0-255].[0-255]");
Matcher matcher = pattern.matcher(Value);
boolean IPcheck = matcher.matches();
if(IPcheck){
boolean IsValidData=true;
String _strServer=((EditText)findViewById(R.id.txtserver)).getText().toString().trim();
}
//it is IP
else{
Toast.makeText(getBaseContext(), "Please Check Your IP Format: ", Toast.LENGTH_SHORT).show();
}
//it is not IP
}
public void loginbuttonclick(View v)
{
ProgressDialog pDialog = new ProgressDialog(LoginActivity.this);
// Set progressbar title
pDialog.setTitle("Authentication");
// Set progressbar message
pDialog.setMessage("Authenticating...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
// Show progressbar
pDialog.show();
try
{
//Validate input data
boolean IsValidData=true;
String _strServer=((EditText)findViewById(R.id.txtserver)).getText().toString().trim();; //"192.168.0.172";
String _strUser=((EditText)findViewById(R.id.txtuser)).getText().toString().trim();;//"admin";
String _strPass=((EditText)findViewById(R.id.txtpass)).getText().toString();//"admin";
if(_strServer==null || _strServer.isEmpty() || _strServer=="")
{
IsValidData=false;
pDialog.dismiss();
Toast.makeText(getBaseContext(),"Kindly enter valid server ip! : ",Toast.LENGTH_SHORT).show();
}
我尝试过:
对于null和Empty我已经完成了,所以如何放置checkIP?请帮助..
What I have tried:
For null and Empty I have done, so How do I put checkIP? please help..
推荐答案
这篇关于如何在edittext上验证IP以完成此操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!