我想选择财务名称,点击财务名称后,我想获得相同财务的代码。财务名称列在列表视图中。
我的 Firebase 数据库结构如下:
financeRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
//Map<String, Object> data = (Map<String, Object>) snapshot.getValue();
String value = new Gson().toJson(snapshot.getValue());
progressBar.setVisibility(View.GONE);
try {
JSONObject object = new JSONObject(String.valueOf(value));
f = object.getString("Finance Name");
name = snapshot.getKey();
} catch (JSONException e) {
e.printStackTrace();
}
financeName.add(f);
adapter.notifyDataSetChanged();
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(FinanceNameListActivity.this, CodeAndNameActivity.class);
String abc = (String) ((TextView) view).getText();
intent.putExtra("Name",abc);
startActivity(intent);
finish();
}
});
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
一只名叫tom的猫
相关分类