Is there logic that we apply if else on Text of TextView without using integer?
public class MainActivity extends AppCompatActivity {
TextView text;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text=findViewById(R.id.textView1);
button=findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
if (text!=Paint.STRIKE_THRU_TEXT_FLAG)
{
text.setPaintFlags(text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
else
{
text.setPaintFlags(text.getPaintFlags() | ~ Paint.STRIKE_THRU_TEXT_FLAG);
}
}
}
);
}
}
I want to do that, on button click, if the text is normal it will become Strikethrough and if the text is Strikethrough it will become normal.