是否存在我們在不使用整數的情況下在 TextView 的文本上應用 if else 的邏輯?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); } } } ); }}我想這樣做,在單擊按鈕時,如果文本是正常的,它將變為刪除線,如果文本是刪除線,它將變為正常。
如何在不使用任何整數變量的情況下在單擊按鈕時在 Textview 上應用 If Else?
慕桂英3389331
2023-03-02 16:47:15