I have checked my edittext is visible or invisible in android.
Now i have to check the condition is.,
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 editText = (EditText)findViewById(R.id.editText1);
editText.getVisibility();
this will provide the edittext is VISIBLE, INVISIBLE, or GONE.
if(editText.getVisibility() == View.VISIBLE){
//.. your actions are performed here
}
Refer This . You can find some interesting details about VISIBLE , GONE and INVISIBLE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.