【发布时间】:2011-06-20 20:43:42
【问题描述】:
我正在开发一个 Android 应用程序。 该应用程序有一系列表格,我想确认用户在继续下一组表格之前填写了这些表格。最好的方法是什么?
public void goOne()
{
setContentView(R.layout.main);
next = (Button) findViewById(R.id.next);
logo = (Button) findViewById(R.id.logo);
cityText = (EditText)findViewById(R.id.city);
about = (Button) findViewById(R.id.aboutus);
about.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
goAboutUs();
}
});
logo.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
goOne();
}
});
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
city = (String)cityText.getText().toString();
if(stateLoc.equalsIgnoreCase("international"))
{
location = "";
isInternational = 1;
}else
{
location = city;
}
if(cityText.getText().equals("") && stateLoc.equalsIgnoreCase("U.S.A"))
{
new AlertDialog.Builder(Tents.this)
.setTitle("Error")
.setMessage("Enter ZIP Code, or choice International ")
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
goOne();
}
}).show();
}else{
goTwo();
}
}
});
那是我的代码。我正在尝试验证 cityText 文本框。如果里面没有任何东西并且 stateLoc 设置为 U.S.A 然后弹出警报如果没有然后 goTwo()
【问题讨论】:
标签: java android validation forms