У меня возникают некоторые проблемы при передаче данных из одного действия в другое, при щелчке по элементу я хочу передать значение элемента, по которому щелкнули, другому действию, в следующем коде это только последний фрагмент данных, а не элемент, по которому был выполнен щелчок.любая помощь очень ценится.
public class list_view extends AppCompatActivity {
private ArrayAdapter<String> arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view);
final String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
final DatabaseReference uidRef = rootRef.child("ProgressReports").child(uid);
final List<String> list = new ArrayList<>();
final ArrayList<String> id = new ArrayList<>();
final Context context = this;
EditText searchBarProgress = findViewById(R.id.searchBarProgress);
arrayAdapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_list_item_1, list);
String key = uidRef.push().getKey();
ReportInformation report = new ReportInformation();
report.setTitle("title");
report.setContent("content");
report.setKey(key);
uidRef.child(key).setValue(report);
ValueEventListener eventListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren()) {
id.add(ds.getKey());
String title = ds.child("title").getValue(String.class);
String content = ds.child("content").getValue(String.class);
String timestamp = ds.child("timestamp").getValue(String.class);
list.add(title + "\n" + timestamp + "\n" + content);
Log.d("TAG", title);
}
ListView listView = findViewById(R.id.progressList);
listView.setAdapter(arrayAdapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
};
uidRef.addListenerForSingleValueEvent(eventListener);
final ListView progressList = findViewById(R.id.progressList);
progressList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int x, long l) {
ValueEventListener eventListener = new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
ArrayList<ReportInformation> list = new ArrayList<>();
for (DataSnapshot ds : dataSnapshot.getChildren()) {
ReportInformation report = ds.getValue(ReportInformation.class);
list.add(report);
}
Intent intent = new Intent(list_view.this, ProgressReports.class);
ListView listView = findViewById(R.id.progressList);
listView.setAdapter(arrayAdapter);
startActivity(intent);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
}
});
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
};
uidRef.addListenerForSingleValueEvent(eventListener);
}
});
Чтобы показать, что я имею в виду, независимо от того, какую кнопку я нажимаю в следующем просмотре списка, переданные данные являются Тест 4


Ниже моя структура базы огня

Класс модели для объектов
public class ReportInformation {
private String title;
private String content;
private String timestamp;
private String key;
public ReportInformation(){
}
public String getTitle() {
return title;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
}
Получение следующей ошибки при попытке сделать это

Новая ошибка 
