当所选值= 0时,如何使用微调器的if statement
if( wilayat.setSelection(0) || city.setSelection(0) ||
station.setSelection(0) || distnation.setSelection(0)) {
message = "Select the 4 fields, please..";
Toast.makeText(BusArrivalTime.this, message, Toast.LENGTH_SHORT).show();
}
答案 0 :(得分:0)
试试这个。
import org.testng.annotations.Test;
public class MyTestClass implements ILogout {
@Test(priority = 1, groups = {"Regression"})
@Logout //We need a selective logout to be performed for this method.
public void createaccount() throws Exception {
}
@Test(priority = 2, groups = {"Regression"})
public void addpayment() throws Exception {
}
@Test(priority = 3, groups = {"Regression"})
public void logout() throws Exception {
}
@Test(priority = 4, groups = {"Regression"})
public void login() throws Exception {
}
@Override
public void signout() {
}
}
只需使用import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;
public class MyListener implements IInvokedMethodListener {
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { }
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
Logout logout = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Logout.class);
if (logout == null) {
return;
}
//Try and process only if the method that was just now executed by TestNG has the
//marker annotation.
Object instance = method.getTestMethod().getInstance();
//We were asked to logout, but check if the corresponding test class has an implementation
//for performing the actual logout. If yes, then invoke that directly.
if (instance instanceof ILogout) {
((ILogout) instance).signout();
}
}
}
方法。
您确保if (wilayat.getSelectedItemPosition() == 0 || city.getSelectedItemPosition() == 0 || station.getSelectedItemPosition() == 0 || distnation.getSelectedItemPosition() == 0) {
message = "Select the 4 fields, please..";
Toast.makeText(BusArrivalTime.this, message, Toast.LENGTH_SHORT).show();
}
,getSelectedItemPosition()
等是Spinner。
添加判断
wilayat