views:

71

answers:

2
+1  Q: 

Android edit text

I am working with an edit text to support the properties of bold,italic and underline.I got succeed after selecting the text and clicking on bold my text was bold.Now what my requirement is how to remove the bold again after selecting the text and clicking on bold button.

Regards,

Bhavani.G

A: 

You need to keep a bold flag so that you check the current status of the flag and do the opposite.

Some thing like this:

Boolean isBold = false;
.
.
.
boldText()
{
  if(isBold){
      //unbold 
      setTypeface( <What you need> )
      isbold=false;
  }
  else {
      //bold 
      setTypeface( <What you need> )
      isbold=true;
  }
}
Ravi Vyas
A: 

It is not simply setting the flag to do bold and remove the bold.We have to know the text we have selected is in bold and if it is bold then we have to remove the bold by clicking the same button..

Regards,

Bhavani

vani