[英]Android The method startActivity(Intent) is undefined for the type new View.OnClickListener(){}
[英]The method userAccounts() is undefined for the type new View.OnClickListener(){}
我有一個userAccounts類,該類聲明我的用戶帳戶的所有變量。 但是當試圖增加按鈕上的userAccounts類型的arrayList的大小時,我得到了錯誤。
The method userAccounts() is undefined for the type new View.OnClickListener(){}
代碼是:
public class CreateAccount extends Activity {
ArrayList<userAccounts> accountArray = new ArrayList<userAccounts>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_account);
final Button buttonCreate = (Button) findViewById(R.id.btnCreate);
buttonCreate.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
accountArray.add(userAccounts());
如果您想將新項目添加到列表中,則應該將accountArray.add(userAccounts())
更改為accountArray.add(new userAccounts())
。 您的變體假設您調用了專門用於偵聽器類的一些方法userAccounts()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.