2013-12-15 63 views
1

我有一個userAccounts類聲明的所有變量對我的用戶帳戶。但是,當試圖增加一個按鈕類型的userAccounts arrayList的大小時按我得到的錯誤。方法userAccounts()是未定義的類型新View.OnClickListener(){}

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()); 
+0

您應該考慮遵循Java標準命名約定。類名應以大寫字母開頭。你有它的方式使它看起來像你的'活動'裏面的功能 – codeMagic

回答

1

也許,如果你想新的項目添加到列表中,你應該改變accountArray.add(userAccounts())accountArray.add(new userAccounts())。 您的變體假設您調用專用於偵聽器類的一些方法userAccounts()

+0

謝謝你做到了! – mossypne

相關問題