【发布时间】:2016-01-21 18:45:26
【问题描述】:
我正在尝试显示从 Microsoft Band 获取的心率,例如每 20 秒 6 次。在这种情况下,我创建了 6 个文本视图,我将从乐队中读取读数并将其显示在 6 个文本视图上。但是,如何在 6 个文本视图上显示所有 6 个读数?到目前为止,我只能在第一个文本视图上显示一个读数。知道如何使用 may for 循环或 if else 每 20 秒显示其他 5 个读数吗?
我的代码读取心率并将其转换为字符串:
public void onHeartrateClick(View v){
if(v.getId() == R.id.Bhistory){
TextView e = (TextView)findViewById(R.id.txtHeart);
String string = e.getText().toString();
Intent i = new Intent(Pulse.this, History.class);
i.putExtra("History", string);
startActivity(i);
}
我在 history.xml 中显示读数的代码:
public class History extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
String history = getIntent().getStringExtra("History");
TextView textView = (TextView)findViewById(R.id.TVhistory);
textView.setText(history);
}
我的 History.xml 图片,其中显示了从乐队中获取的读数:
希望在我为一个项目执行此操作时尽快获得帮助。谢谢你:)
【问题讨论】:
-
你的“读数”是字符串列表吗?