我試圖顯示從微軟樂隊採取心率例如每20秒6次。在這種情況下,我創建了6個文本視圖,然後我將從樂隊中讀取並在6個文本視圖中顯示它。但是,如何在6個文本視圖中顯示全部6個讀數?到目前爲止,我只能在第一個文本視圖中顯示一個閱讀。任何想法如何使用可能爲循環或否則顯示其他5讀數每20秒?如何使用「for循環」或「if和else if」方法每隔X秒和X時間更新多個TextView?
我的代碼,把心臟率讀數並將其轉換爲字符串:
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圖片這顯示從帶中讀取的讀數:
希望能儘快獲得幫助,因爲我正在爲項目做這件事。謝謝:)
是你的'閱讀'的字符串列表? – Boukharist