にバウンスできませんでした。firebaseからデータを取得するアプリケーションをビルドしました。 recyclerviewを使ってデータimを表示すると、私は活動魔女に移動している間にエラーを取得して、火災基地からデータを取得します。使用致命的な例外:main com.firebase.client.FirebaseException:タイプ
E/AndroidRuntime: FATAL EXCEPTION: main
com.firebase.client.FirebaseException: Failed to bounce to type
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:183)
at com.sliit.dailyselfie.ActivityFeed.ActivityFeed.GetDataUpdates(ActivityFeed.java:129)
at com.sliit.dailyselfie.ActivityFeed.ActivityFeed$3.onChildAdded(ActivityFeed.java:156)
at com.firebase.client.core.ChildEventRegistration.fireEvent(ChildEventRegistration.java:48)
at com.firebase.client.core.view.DataEvent.fire(DataEvent.java:45)
at com.firebase.client.core.view.EventRaiser$1.run(EventRaiser.java:38)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.sliit.dailyselfie.ActivityFeed.SharePost] from String value; no single-String constructor/factory method
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator._createFromStringFallbacks(StdValueInstantiator.java:428)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:299)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1056)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:136)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:123)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2888)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2034)
at com.firebase.client.DataSnapshot.getValue(DataSnapshot.java:181)
at com.sliit.dailyselfie.ActivityFeed.ActivityFeed.GetDataUpdates(ActivityFeed.java:129)
at com.sliit.dailyselfie.ActivityFeed.ActivityFeed$3.onChildAdded(ActivityFeed.java:156)
at com.firebase.client.core.ChildEventRegistration.fireEvent(ChildEventRegistration.java:48)
at com.firebase.client.core.view.DataEvent.fire(DataEvent.java:45)
at com.firebase.client.core.view.EventRaiser$1.run(EventRaiser.java:38)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
クラスは SharePost.java
@JsonIgnoreProperties(ignoreUnknown=true)
public class SharePost {
private String PostSharer;
private String PostType;
private String PostImage;
private String PostDescription;
private String PostedTime;
@JsonIgnore
private String PostID;
public SharePost(){}
public SharePost(String postSharer, String postType, String postImage, String postDescription, String postedTime, String postID) {
PostSharer = postSharer;
PostType = postType;
PostImage = postImage;
PostDescription = postDescription;
PostedTime = postedTime;
PostID = postID;
}
public String getPostSharer() {
return PostSharer;
}
public void setPostSharer(String postSharer) {
PostSharer = postSharer;
}
public String getPostType() {
return PostType;
}
public void setPostType(String postType) {
PostType = postType;
}
public String getPostImage() {
return PostImage;
}
public void setPostImage(String postImage) {
PostImage = postImage;
}
public String getPostDescription() {
return PostDescription;
}
public void setPostDescription(String postDescription) {
PostDescription = postDescription;
}
public String getPostedTime() {
return PostedTime;
}
public void setPostedTime(String postedTime) {
PostedTime = postedTime;
}
}
私は
public class ActivityFeed extends AppCompatActivity {
BottomBar mBottomBar;
ArrayList<SharePost> SharedPosts;
RecyclerView RV;
AdapterAC adapterAC;
Firebase fire;
Dialog d;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_feed);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Firebase.setAndroidContext(this);
SharedPosts = new ArrayList<>();
fire=new Firebase("https://dailyselfie.firebaseio.com/SharePost");
RV= (RecyclerView)findViewById(R.id.recycler1);
RV.setLayoutManager(new LinearLayoutManager(this));
mBottomBar = BottomBar.attach(this, savedInstanceState);
mBottomBar.noNavBarGoodness();
// this.RefreshData();
mBottomBar.setItemsFromMenu(R.menu.bottomba_menu, new OnMenuTabClickListener() {
@Override
public void onMenuTabSelected(@IdRes int menuItemId) {
if (menuItemId == R.id.nav_home) {
Toast.makeText(ActivityFeed.this, "Timeline", Toast.LENGTH_SHORT).show();
} else if (menuItemId == R.id.nav_fav) {
showD();
} else if (menuItemId == R.id.nav_gallery) {
Toast.makeText(ActivityFeed.this, "Favorites", Toast.LENGTH_SHORT).show();
}
mBottomBar.mapColorForTab(0, ContextCompat.getColor(ActivityFeed.this, R.color.bottomPrimary));
mBottomBar.mapColorForTab(1, ContextCompat.getColor(ActivityFeed.this, R.color.bottomPrimary));
mBottomBar.mapColorForTab(2, ContextCompat.getColor(ActivityFeed.this, R.color.bottomPrimary));
}
@Override
public void onMenuTabReSelected(@IdRes int menuItemId) {
}
});
this.RefreshData();
}
@Override
protected void onStart() {
super.onStart();
}
public void RetriveData(){
fire.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
GetDataUpdates(dataSnapshot);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
GetDataUpdates(dataSnapshot);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
public void GetDataUpdates(DataSnapshot dataSnapshot){
SharedPosts.clear();
for(DataSnapshot ds: dataSnapshot.getChildren()){
SharePost sp = new SharePost();
sp.setPostSharer(ds.getValue(SharePost.class).getPostSharer());
sp.setPostType(ds.getValue(SharePost.class).getPostType());
sp.setPostDescription(ds.getValue(SharePost.class).getPostDescription());
sp.setPostImage(ds.getValue(SharePost.class).getPostImage());
sp.setPostedTime(ds.getValue(SharePost.class).getPostedTime());
SharedPosts.add(sp);
}
if(SharedPosts.size()>0){
adapterAC = new AdapterAC(ActivityFeed.this,SharedPosts);
RV.setAdapter(adapterAC);
}else{
Toast.makeText(ActivityFeed.this, "No data available", Toast.LENGTH_SHORT).show();
}
}
public void RefreshData(){
fire.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
GetDataUpdates(dataSnapshot);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
GetDataUpdates(dataSnapshot);
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
public void save(String name,String type,String description,String date){
SharePost sp = new SharePost();
sp.setPostSharer(name);
sp.setPostType(type);
sp.setPostDescription(description);
sp.setPostedTime(date);
fire.push().setValue(sp);
d.dismiss();
}
public void showD(){
d= new Dialog(ActivityFeed.this);
d.setTitle("Save data");
d.setContentView(R.layout.shr);
final EditText name = (EditText)d.findViewById(R.id.editText);
final EditText type = (EditText)d.findViewById(R.id.editText2);
final EditText description = (EditText)d.findViewById(R.id.editText3);
final EditText date = (EditText)d.findViewById(R.id.editText4);
Button b = (Button)d.findViewById(R.id.button);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
save(name.getText().toString(),type.getText().toString(),description.getText().toString(),date.getText().toString());
name.setText("");
type.setText("");
description.setText("");
date.setText("");
}
});
d.show();
}
}
をコーディングfirebase検索を使用するクラスどこWHEそれはいいだろう、誰かが説明できる理由は、このエラーを取得イムそれを避ける方法。
ありがとうございました。addChildEventListener()をaddValueEventListener()に変更しました。 。 – TRomesh