可见的EditText意味着我如何检查,如果条件的android [英] edittext visible means how can i check the if condition in android
问题描述
我已经检查了我的EditText是Android中可见或不可见。
现在我要检查的条件。
- 如果我的EditText是可见的方式我怎样才能插入数据。
- 如果我的EditText消失意味着我怎么可以插入另一个数据。
这是我的$ C $下,如果我要选中复选框意味着EditText上是看不到的,否则的EditText是可见的:
chkIos =(复选框)findViewById(R.id.addresscheckbox);
chkIos.setOnClickListener(新View.OnClickListener(){
公共无效的onClick(视图v){
如果(((复选框)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);
}
其他
{
S_address =(TextView中)findViewById(R.id.address1);
S_address.setVisibility(View.VISIBLE);
Saddress =(EditText上)findViewById(R.id.tf_address1);
Saddress.setVisibility(View.VISIBLE);
如果(!(Saddress.getText()的toString()长度()== 0)){
showAlertbox(送货地址是必需的!);
}
}
下面code是,如果我的EditText是可见的方式插入到saddr value.otherwise插入baddr value.how我可以检查的条件。
下面以下错误显示: 可见不能被解析为一个变量。
如果(Saddress ==可见)
{
的PropertyInfo saddress =新的PropertyInfo();
saddress.setName(Saddress); //定义在Web服务方法的变量名
saddress.setValue(SADDR); //定义值FNAME变量
saddress.setType(为String.class); //定义变量的类型
request.addProperty(saddress); //通行证属性到可变
}
其他
{
的PropertyInfo saddress =新的PropertyInfo();
saddress.setName(Saddress); //定义在Web服务方法的变量名
saddress.setValue(baddr); //定义值FNAME变量
saddress.setType(为String.class); //定义变量的类型
request.addProperty(saddress); //通行证属性到可变
}
请参阅完整的源代码code在这里:满code
编辑:
在我的codeI必须选中复选框意味着Saddress是无形的know.that时候,我必须按一下按钮意味着插入baddr值...如果我不得不取消选中该复选框意味着Saddress值visible.that时候我已经插入SADDR值。
在这里,我需要运行的应用程序意味着baddr值insered两个Saddress ==可见和Saddess ==无形case.how可我写的条件这些。
使用
如果(Saddress.getVisibility()== View.VISIBLE){
// ..您的code在这里
}
而不是
如果(Saddress ==可见){
// ..您的code在这里
}
由于可见
, GONE
和看不见
的一部分View类,而不是活性
I have checked my edittext is visible or invisible in android.
Now i have to check the condition is.,
- If my edittext is visible means how can i insert the data.
- If my edittext is gone means how can i insert on another data.
This is my code for if i have to check the checkbox means the edittext is invisible otherwise the edittext is visible .:
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!!");
}
}
The below code is ., if my edittext is visible means insert the saddr value.otherwise insert the baddr value.how can i check the condition.
Here below error is showing: VISIBLE cannot be resolved to a variable.
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
}
please see the full source code here:full code
EDIT:
In my code i have to check the checkbox means the Saddress is invisible know.that time i have to click the button means the baddr value is inserted...If i have to uncheck the checkbox means the Saddress value is visible.that time i have to insert the saddr value.
Here i have to run the app means the baddr value is insered both Saddress==visible and Saddess==invisible case.how can i write the condition for these.
use
if(Saddress.getVisibility() == View.VISIBLE){
//.. your code here
}
instead of
if(Saddress== VISIBLE){
//.. your code here
}
because VISIBLE
,GONE
and INVISIBLE
is part of View class instead of Activity
这篇关于可见的EditText意味着我如何检查,如果条件的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!