我已经检查过我的编辑文本在 Android 中是可见还是不可见。
现在我必须检查条件是.,
- 如果我的编辑文本可见意味着我如何插入数据。
- 如果我的编辑文本消失了意味着我如何插入另一个数据。
这是我的代码,如果我必须选中复选框,则意味着编辑文本不可见,否则编辑文本可见。:
chkIos = (CheckBox) findViewById(R.id.addresscheckbox);
chkIos.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (((CheckBox) v).isChecked())
{
S_address = (TextView)findViewById(R.id.address1);
S_address.setVisibility(View.GONE);
Saddress = (EditText)findViewById(R.id.tf_address1);
Saddress.setVisibility(View.GONE);
}
else
{
S_address = (TextView)findViewById(R.id.address1);
S_address.setVisibility(View.VISIBLE);
Saddress = (EditText)findViewById(R.id.tf_address1);
Saddress.setVisibility(View.VISIBLE);
if(!(Saddress.getText().toString().length() == 0)){
showAlertbox(" Shipping Address is Required!!");
}
}
下面的代码是。,如果我的编辑文本可见,则意味着插入 baddr 值。否则插入 baddr 值。我如何检查条件。
下面显示错误:
VISIBLE 无法解析为变量。
if(Saddress== VISIBLE)
{
PropertyInfo saddress =new PropertyInfo();
saddress.setName("Saddress");//Define the variable name in the web service method
saddress.setValue(saddr);//Define value for fname variable
saddress.setType(String.class);//Define the type of the variable
request.addProperty(saddress);//Pass properties to the variable
}
else
{
PropertyInfo saddress =new PropertyInfo();
saddress.setName("Saddress");//Define the variable name in the web service method
saddress.setValue(baddr);//Define value for fname variable
saddress.setType(String.class);//Define the type of the variable
request.addProperty(saddress);//Pass properties to the variable
}
请在此处查看完整的源代码:完整代码
EDIT:
在我的代码中,我必须选中该复选框意味着 Saddress 是不可见的。当时我必须单击该按钮意味着 baddr 值已插入...如果我必须取消选中该复选框意味着 Saddress 值是可见的。那时我必须插入saddr值。
在这里,我必须运行该应用程序,这意味着 baddr 值同时插入了 Address==visible 和 Sadness==invisible 的情况。我如何编写这些条件。
use
if(Saddress.getVisibility() == View.VISIBLE){
//.. your code here
}
代替
if(Saddress== VISIBLE){
//.. your code here
}
because VISIBLE
,GONE
and INVISIBLE
是 View 类的一部分,而不是 Activity 的一部分
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)