我正在编写一个更新到firebase的应用程序,但是我不能编写oncancelled函数,因为它cannot resolve symbol FirebaseError
。
我的代码如下:
package com.test.myapplication;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;
import static com.test.myapplication.R.id.radioButton5;
import static com.test.myapplication.R.id.radioButton6;
import static com.test.myapplication.R.id.radioButton8;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
public class OfficialDetail extends AppCompatActivity {
TextView textViewStreet;
TextView textViewLat;
TextView textViewLong;
TextView textViewDescription;
TextView textViewSeverity;
TextView textViewSize;
TextView textViewEmail;
RadioButton RadioButton5;
RadioButton RadioButton6;
RadioButton RadioButton8;
DatabaseReference mRef;
DatabaseReference dRef;
ArrayList<Report> reportArrayList;
Report value;
ListView mListView;
ImageView imgView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_item_detail);
RadioButton5 = (RadioButton)findViewById(radioButton5);
RadioButton6 = (RadioButton)findViewById(radioButton6);
RadioButton8 = (RadioButton)findViewById(radioButton8);
Intent intent = getIntent();
initialize();
if(intent!=null) {
textViewStreet.setText(intent.getStringExtra("street_of"));
textViewLat.setText(intent.getStringExtra("lat_of"));
textViewLong.setText(intent.getStringExtra("long_of"));
textViewDescription.setText(intent.getStringExtra("descrip_of"));
textViewSeverity.setText(intent.getStringExtra("severity_of"));
textViewSize.setText(intent.getStringExtra("size_of"));
if(intent.getStringExtra("Off").equals("Official")){
RadioButton5.setEnabled(false);
RadioButton8.setEnabled(false);
}else{
RadioButton5.setEnabled(false);
RadioButton6.setEnabled(false);
}
if (RadioButton6.isChecked()){
reportArrayList = new ArrayList<>();
dRef = FirebaseDatabase.getInstance().getReference();
mRef = dRef.child("report");
Query qRef;
qRef = dRef.orderByChild("Status").equalTo("still_there");
qRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot tasksSnapshot) {
for (DataSnapshot snapshot: tasksSnapshot.getChildren()) {
snapshot.getRef().child("Status").setValue("removal_confirmed");
}
}
@Override
public void onCancelled(**FirebaseError** firebaseError) {
System.out.println("The read failed: " + firebaseError.getMessage());
}
});
}
byte[] decodedString = Base64.decode(intent.getStringExtra("img_of"), Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
imgView.setImageBitmap(decodedByte);
}
}
private void initialize(){
textViewStreet = (TextView) findViewById(R.id.textView22);
imgView = (ImageView) findViewById(R.id.imageView);
textViewDescription = (TextView) findViewById(R.id.item_detail);
textViewSeverity = (TextView) findViewById(R.id.textView24);
textViewSize = (TextView) findViewById(R.id.textView26);
textViewLat = (TextView) findViewById(R.id.textView13);
textViewLong = (TextView) findViewById(R.id.textView17);
}
}
有我遗漏的陈述吗?我该怎么解决?
最佳答案
尝试用FirebaseError
类更改DatabaseError
类。
我也有同样的问题,我所做的只是删除了所有的方法代码,并允许android工作室自己创建方法定义。然后FirebaseError
自动替换为DatabaseError
。
关于android - FirebaseError无法解决,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41214937/