简体   繁体   English

对于新的View.OnClickListener(){}类型,未定义方法userAccounts()

[英]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.

相关问题 Android对于new View.OnClickListener(){}类型,未定义方法startActivity(Intent) - Android The method startActivity(Intent) is undefined for the type new View.OnClickListener(){} 未定义类型为new View.OnClickListener(){} - Undefined for the type new View.OnClickListener(){} 新的View.OnClickListener类型必须实现继承的抽象方法 - The type new View.OnClickListener must implement the inherited abstract method 视图类型中的方法setOnClickListener(View.OnClickListener)不适用于自变量(新DialogInterface.OnClickListener(){}) - The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){}) @override错误:类型为new View.OnClickListener(){}的方法onClick(View)必须重写超类方法 - @override error: The method onClick(View) of type new View.OnClickListener(){} must override a superclass method new View.OnClickListener(){}类型的方法onClick(View,String)从未在本地使用 - The method onClick(View, String) from the type new View.OnClickListener(){} is never used locally 构造函数Intent(new View.OnClickListener(){},类 <ChangePasswordActivity> )未定义 - The constructor Intent(new View.OnClickListener(){}, Class<ChangePasswordActivity>) is undefined 新的OnClickListener()与新的View.OnClickListener() - new OnClickListener() vs new View.OnClickListener() 视图类型中的方法setOnClickListener(View.OnClickListener)不适用于自变量(起点) - The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (startingpoint) View.OnClickListener,方法还是类? - View.OnClickListener, method or class?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM