0
我得到運行時空點異常在我的Android應用程序。我得到運行時空點異常在我的Android應用程序
所致:顯示java.lang.NullPointerException:嘗試調用虛擬方法「com.google.firebase.database.ChildEventListenercom.google.firebase.database.Query.addChildEventListener(com.google.firebase.database.ChildEventListener )」對空對象引用
這裏是我的火力地堡連接:
package com.example.nagesh.newapp;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import com.firebase.ui.database.FirebaseListAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class Last extends AppCompatActivity {
private ListView lst;
private DatabaseReference databaseReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_last);
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl("https://newapp-46492.firebaseio.com/Users");
init();
}
private void init() {
lst = (ListView) findViewById(R.id.lstv);
FirebaseListAdapter<String> firebaseListAdapter = new FirebaseListAdapter<String>(this, String.class, android.R.layout.simple_list_item_1, databaseReference) {
@Override
protected void populateView(View v, String model, int position) {
TextView textView = (TextView) v.findViewById(android.R.id.text1);
textView.setText(model);
}
};
lst.setAdapter(firebaseListAdapter);
}
}
我是初學者....幫幫我吧。
凡引用是ChildEventListener?請分享更多的代碼。 –