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());
您應該考慮遵循Java標準命名約定。類名應以大寫字母開頭。你有它的方式使它看起來像你的'活動'裏面的功能 – codeMagic