自定义ArrayAdapter在更改Activity后将数据集更改为以前的状态

时间:2019-03-10 18:33:00

标签: android android-listview android-arrayadapter

我想在Upgrades上执行更新,当我在Item上单击某些ListView时,它会被更新,但随后我必须回到另一个{{1} }。当我将Activity改回以前的版本时,在更新之前会看到Activity

我的自定义Items

Adapter

处理点击事件,执行public class UpgradeAdapter extends ArrayAdapter<Upgrade> { private List<Upgrade> upgrades; public UpgradeAdapter(Context context, List<Upgrade> upgrades) { super(context,0,upgrades); this.upgrades = upgrades; } @Override public View getView(int position, View convertView, ViewGroup parent) { Upgrade upgrade = getItem(position); if (convertView == null) { convertView = LayoutInflater.from(getContext()). inflate(R.layout.product_list_layout, parent, false); } TextView name = convertView.findViewById(R.id.nameTextField); TextView lvl = convertView.findViewById(R.id.lvlTextField); TextView modifier = convertView.findViewById(R.id.modifierTextField); TextView type = convertView.findViewById(R.id.typeTextField); TextView cost = convertView.findViewById(R.id.costTextField); name.setText(upgrade.getName()); lvl.setText(upgrade.getLvl() + ""); modifier.setText(upgrade.getModifier() + ""); type.setText(upgrade.getType().toString()); cost.setText(upgrade.getCost() + ""); return convertView; } }

notifyDataSetChanged()

0 个答案:

没有答案