我试图通过我的Intent将数据传递到下一个活动,这样我就可以收到它并给出一个计时器值.
Button TimerButton = (Button)findViewById(R.id.TimerActivityButton);
TimerButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
Intent timer = new Intent (BeefActivity.this,TimerActivity.class);
timer.putExtra("beefType", 5000);
timer.putExtra("beefThickness", 5000);
timer.putExtra("grillTime", 15000);
startActivity(timer);
}
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试了不同的接收值的方法,并且我不断收到强制关闭或编译器错误.我知道这很简单所以有人可以告诉我如何做到这一点.先感谢您!
This is force closing
Run Code Online (Sandbox Code Playgroud)
只是拥有int beefType = getIntent().getIntExtra("beefType", -1);
我班级的顶级才能让它靠近.没有编译器错误.我被困了:-(这是我的代码看起来如何
package com.android.project1;
import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class TimerActivity extends Activity {
int beefType = getIntent().getIntExtra("beefType", 200);
TextView timeDisplay;
MyCount counter;
int state = …
Run Code Online (Sandbox Code Playgroud)