我想选择财务名称,点击财务名称后,我想获得相同财务的代码。财务名称列在列表视图中。我的 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) { }});
1 回答
一只名叫tom的猫
TA贡献1906条经验 获得超3个赞
从 firebase 获取响应并将其设置为模型调用或哈希映射或数组,然后实现列表视图单击事件或简单单击事件的接口,并获取位置并从设置 firebase 响应的位置获取值。
添加回答
举报
0/150
提交
取消