簡體   English   中英

Android Studio 錯誤“賦值不是表達式,在此上下文中只允許使用表達式。”

[英]Android Studio Error “Assignments are not expressions, and only expressions are allowed in this context.”

我正在嘗試使用此代碼單擊按鈕更改 TextView 中的文本:

    button_change_text.setOnClickListener(
        textView3.text="Hello World!"
    )

我在許多教程視頻和論壇上都看到了它,但是當我嘗試構建應用程序時出現以下錯誤:

賦值不是表達式,在此上下文中只允許使用表達式。

我究竟做錯了什么?

button_change_text.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
     textView3.setText("Hello World!"); 
   }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM