我可以更改customArray中的项目吗?

时间:2017-12-05 18:00:24

标签: android arrays android-studio

你好我想修改自定义ArrayList中的一些数据

我的自定义数组

public class Item_GetMembers {

    String userid,username,gender,admin,ban,type;

    public Item_GetMembers(String userid, String username, String gender, String admin, String ban, String type) {
        this.userid = userid;
        this.username = username;
        this.gender = gender;
        this.admin = admin;
        this.ban = ban;
        this.type = type;
    }
}

我想修改禁令从0到1位置3我可以在同一页面上进行吗?

我的适配器

 public class Adapter_GetMembers extends RecyclerView.Adapter<Adapter_GetMembers.AdapterHolder>{

        ArrayList<Item_GetMembers> CategoriesList;
        Context context;

        public Adapter_GetMembers(Context context , ArrayList<Item_GetMembers> categories) {
            this.context = context;
            CategoriesList = categories;
        }

        @Override
        public AdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_getmembers,parent,false);
            AdapterHolder adapterHolder = new AdapterHolder(v);

            return adapterHolder;
        }

        @Override
        public void onBindViewHolder(final AdapterHolder holder, final int position) {
            final Item_GetMembers item_getMembers = CategoriesList.get(position);
item_getMembers.ban.get(3,1); //but wrong why??

        }

        @Override
        public int getItemCount() {
            return CategoriesList.size();
        }

        class AdapterHolder extends RecyclerView.ViewHolder
        {

            public AdapterHolder(View itemView) {
                super(itemView);

            }
        }

}

我可以编辑其中的数据吗?我尝试了很多来修改它,但它没有用   ,提前谢谢

1 个答案:

答案 0 :(得分:0)

试试这个

Ł