[英]The method userAccounts() is undefined for the type new View.OnClickListener(){}
I've got a userAccounts class that declares all the variables for my user accounts. 我有一个userAccounts类,该类声明我的用户帐户的所有变量。 But when trying to increase the size of an arrayList of type userAccounts on a button press i get the error.
但是当试图增加按钮上的userAccounts类型的arrayList的大小时,我得到了错误。
The method userAccounts() is undefined for the type new View.OnClickListener(){}
The code is: 代码是:
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());
Probably, if you want to add new item to your list, you should change accountArray.add(userAccounts())
to accountArray.add(new userAccounts())
. 如果您想将新项目添加到列表中,则应该将
accountArray.add(userAccounts())
更改为accountArray.add(new userAccounts())
。 Your variant supposes that you call some method userAccounts()
dedicated to the listener class. 您的变体假设您调用了专门用于侦听器类的一些方法
userAccounts()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.