实现在dialog中输入文段,点击新增后gridview中会增加新的item,
item的字段为dialog中的输入文本
dialog.setOnClickListener(R.id.add_refuse, new View.OnClickListener() { @Override public void onClick(View v) { EditText et_message = (EditText) dialog.getId(R.id.et_message); String newreason = et_message.getText().toString(); if (TextUtils.isEmpty(newreason)) { Toast(mContext, "尚未填写新增原因", 2); return; } GetTagResBean.DataBean dataBean = new GetTagResBean.DataBean(); dataBean.setTagName(newreason); addTagResBeanLCommonAdapter.add(dataBean); addTagResBeanLCommonAdapter.notifyDataSetChanged(); }
其中dataBean为本地声明的实体类对象
GetTagResBean.DataBean dataBean = new GetTagResBean.DataBean();
声明的对象格式要与gridview的adapter一致
private LCommonAdapter<GetTagResBean.DataBean> addTagResBeanLCommonAdapter;