所以我有一個非常基本的問題。我的代碼基本上是這樣的Java代碼:更改變量值
用戶檢查一個無線電按鈕選擇一個時間(他們有1小時,2和3),然後點擊從Activity1的按鈕,然後他們被帶到Activity2,它有一個TextView中顯示的時間不多了以秒
我希望部分是清楚現在
,TextView的在活性2應該會顯示來自活性1路過的傳遞時間在這條線從活動1
時間intent.putExtra(「Time」,time);
每當我嘗試這個代碼,結果我得到的是始終爲0,好像根據它是不會改變的時間值我if語句我已經包括了每一個單選按鈕器isChecked塊內。那麼,幫忙?我知道必須有一個非常簡單和容易的解決方案。
謝謝。
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.release_bicycle);
one = (RadioButton)findViewById(R.id.oneHour);
two = (RadioButton)findViewById(R.id.twoHours);
three = (RadioButton)findViewById(R.id.threeHours);
Go = (Button)findViewById(R.id.releaseBTN);
Go.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
//start bluetooth
if (one.isChecked())
{
new CountDownTimer(3600000, 1000)
{
public void onTick(long millisUntilFinished)
{
time = (millisUntilFinished/1000);
}
public void onFinish()
{
... database
}
}.start();
}
if (two.isChecked())
{
...
}
if (three.isChecked())
{
...
}
Intent intent = new Intent(current.this, destination.class);
intent.putExtra ("Time", time);
startActivity(intent);
}
});
}
我把這個行的'time'的值:'intent.putExtra(「Time」,time);'是0? –
@AleksanderLidtke是 –
爲什麼不在Activity2中啓動倒數計時器? – njzk2