我是使用Firebase進行Android開發的新手。我被困在傳遞新的活動的意圖。我想在回收站視圖中點擊特定的卡片時,將url和url1傳遞給新的活動。如何將意圖傳遞給Firebase的新活動recyclerview
這裏是我的代碼
MainActivity
myRef = FirebaseDatabase.getInstance().getReference("project").child("electronics");
recyclerView = (RecyclerView) findViewById(R.id.recycle);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
FirebaseRecyclerAdapter<Project,BlogViewHolder> adapter = new FirebaseRecyclerAdapter<Project, BlogViewHolder>(
Project.class,
R.layout.card,
BlogViewHolder.class,
myRef
) {
@Override
protected void populateViewHolder(BlogViewHolder viewHolder, Project model, int position) {
viewHolder.setProjectName(model.getProjectName());
viewHolder.setUrl1(model.getUrl1());
progressDialog.hide();
}
};
recyclerView.setAdapter(adapter);
}
public static class BlogViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView project1;
ImageView imageview;
public BlogViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
project1 = itemView.findViewById(R.id.textView);
imageview = itemView.findViewById(R.id.projectImage);
}
public void setProjectName(String projectName) {
project1.setText(projectName);
}
public void setUrl1(String url1) {
Picasso.with(itemView.getContext())
.load(url1)
.into(imageview);
}
Project.java
public class Project {
private String projectName,url,url1;
public Project() {
}
public Project(String projectName, String url, String url1) {
this.projectName = projectName;
this.url = url;
this.url1 = url1;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrl1() {
return url1;
}
public void setUrl1(String url1) {
this.url1 = url1;
}}
這裏是我的火力地堡數據庫 Database
的可能的複製[Android的:使用意圖啓動任何活動(https://stackoverflow.com/questions/30959496/android-using-an-intent-to-start-any-activity) – DeKaNszn