我创建了AllUsersActivity,它必须在其中获取并显示所有注册用户。但它崩溃并返回MainActivity。也许这行有错误:Picasso.get().load(user_image).into(image);
如果需要查看更多代码,请写评论。
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;
import de.hdodenhof.circleimageview.CircleImageView;
public class AllUsersActivity extends AppCompatActivity {
private Toolbar mToolbar;
private RecyclerView allUsersList;
private DatabaseReference allDatabaseUserReference;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_users);
mToolbar = (Toolbar) findViewById(R.id.all_users_app_bar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("All Users");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
allUsersList = (RecyclerView) findViewById(R.id.all_users_list);
allUsersList.setHasFixedSize(true);
allUsersList.setLayoutManager(new LinearLayoutManager(this));
allDatabaseUserReference = FirebaseDatabase.getInstance().getReference().child("Users");
}
相关分类