我的Firebase数据库存在问题。
当我从数据库获取数据时,我将旧数据放在顶部。如何更改它以获取最新数据?
in firebase console new data also are at the bottom
我正在使用listView for FirebaseAdapter。
// setting adapter
private void showAdapter() {
fBListAdapter = new FirebaseListAdapter<DiscountProduct>(ListDiscountActivity.this, DiscountProduct.class, R.layout.model_of_product, refDiscount) {
@Override
protected void populateView(View v, DiscountProduct model, int position) {
TextView nameProduct;
nameProduct = (TextView) .findViewById(R.id.modelCardNameProduct);
nameProduct.setText(model.getNameProduct());
}
};
listofDiscountProducts.setAdapter(fBListAdapter); //It's ListView on Activity
}
无法在firebase数据库中添加新数据
//adding data to firebase database
public static void createNewDiscountPost(String nameProduct) {
String key = refDiscount.push().getKey();
DiscountPost discountPost = new DiscountPost(nameProduct);
Map<String, Object> createNewDiscountPost = discountPost.toMap();
Map<String, Object> childUpdates = new HashMap<>();
childUpdates.put("/" + key, createNewDiscountPost);
refDiscount.updateChildren(childUpdates);
}
答案 0 :(得分:3)
使listview适配器中的Sub Macro6()
'
' Macro6 Macro
'
'ActiveWindow.SmallScroll Down:=-12
Range("A1:A381").Select
Selection.FormatConditions.Add Type:=xlTextString, String:="Totals:",
TextOperator:=xlContains
'
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
' With Selection.FormatConditions(1).Font
' .Color = -16383844
' .TintAndShade = 0
' End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615 '16777215 '
.TintAndShade = 0
End With
'Selection.FormatConditions(1).StopIfTrue = False
'lastrow = Sheet4.Cells(Sheet4.Rows.Count, "A").End(xlUp).Row
If Sheet1.Cells(9, 1).Interior.Color = 13551615 Then '16777215
MsgBox ("yes")
Else
MsgBox ("wrong")
MsgBox (Sheet4.Cells(6, 1).Interior.Color)
End If
End Sub
以相反的顺序返回您的项目
getitem
或者您可以尝试@Override
public Object getItem(int position) {
return super.getItem(super.getCount() - position - 1);
}