你在听
ButtonState
把它解释成一个数字。但是
钮状
是一个JSON对象,而
payEnabled
是里面的财产
钮状
付款人
,我只将侦听器附加到该属性:
rootRef.child("payEnabled").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
int payEnabled = dataSnapshot.getValue(Integer.class);
Log.e(TAG, "payEnabled = " + payEnabled);
if (payEnabled == 1) {
pulseAnimation();
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
throw databaseError.toException(); // don't ignore errors
}
});