我已经研究这个问题好几个小时了。我很确定我正确地将值 saveLeagueId 分配给了 TextView。
我想要做的是将一个值从 MainActivity 传递到 BowlerActivity。
这是我的代码,它使用意图传递值;
@Override
public void onClick(View view, final int position) {
int leagueId = leaguesList.get(position).getId();
String savedLeagueId = String.valueOf( leagueId );
Intent myIntent = new Intent(MainActivity.this, BowlerActivity.class);
Log.d("Passing League Id ", "Passed Value is " + leagueId);
myIntent.putExtra("leagueId", savedLeagueId);
startActivity(myIntent);
overridePendingTransition(0, 0);
}
我可以看到它实际上是将值传递给 BowlerActivity
2019-07-09 20:47:06.694 8596-8596/ca.vogl.r.tenpinbowlingcompanion D/Passing League Id: Passed Value is 2
2019-07-09 20:47:06.777 8596-8596/ca.vogl.r.tenpinbowlingcompanion D/GETALLBOWLERS-SQL: SQL used = >>>>SELECT * FROM bowlers WHERE league_id = 'null' ORDER BY timestamp DESC<<<<
2019-07-09 20:47:06.785 8596-8596/ca.vogl.r.tenpinbowlingcompanion D/GETALLBOWLERS-CNT: Number of rows retrieved = 0
2019-07-09 20:47:06.786 8596-8596/ca.vogl.r.tenpinbowlingcompanion D/GETALLBOWLERS-CNT: Number of elements in bowlerslist = 0
2019-07-09 20:47:06.786 8596-8596/ca.vogl.r.tenpinbowlingcompanion D/SAVEDLEAGUEID --->: 2
但是,当我尝试将值传递给名为 leagueId 的 TextView 时,它为空。
MM们
慕田峪7331174
相关分类