1
我有一个叫“someThing”的课。我需要将该课程保存到Firebase,而不是“某些东西”,而是“some_thing”。我可以用HashMap保存它,但是我不清楚如何获取值(主要是用于适配器)。如何在Android Firebase数据库中为变量设置不同的名称?
public class Something {
private int someThing;
public Something(int someThing) {
this.someThing = someThing;
}
public int getSomeThing() {
return someThing;
}
public void setSomeThing(int someThing) {
this.someThing = someThing;
}
}
将数据转换成散列映射保存:
public Map<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("some_thing", something_value);
return result;
}
但如何将它们回装入适配器?适配器是基本适配器:
public class SomethingAdapter extends ArrayAdapter<Something> {
public SomethingAdapter(Context context, int resource) {
super(context, resource);
}
}