public class NewAct extends Activity
{
private OnClickListener EnterValue=new OnClickListener()
{
@Override
public void onClick(View v)
{
EditText E1=(EditText)findViewById(R.id.Total);
String value=E1.getText().toString();
Intent intent=new Intent(NewAct.this,PlayClass.class);
Bundle bundle = new Bundle();
//Add your data to bundle
bundle.putString("TotalMatchSticks", value);
//Add the bundle to the intent
intent.putExtras(bundle);
startActivity(intent);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.entervalue);
Button enter=(Button)findViewById(R.id.Enter);
enter.setOnClickListener(EnterValue);
}
}
我还在Manifest文件中添加了这一行:
<activity android:name=".PlayClass" android:label="@string/app_name" />
此NEWAct活动正在崩溃。这是LogCat值:
06-22 12:24:54.392:WARN / dalvikvm(755):threadid = 1:线程退出,未捕获异常(组= 0x4001d800)06-22 12:24:54.442:错误/ AndroidRuntime(755):致命EXCEPTION:main 06-22 12:24:54.442:ERROR / AndroidRuntime(755):java.lang.RuntimeException:无法启动活动ComponentInfo {com.matchsticks / com.matchsticks.PlayClass}:
答案 0 :(得分:0)
您好,请使用以下代码。
Intent intent=new Intent(NewAct.this,PlayClass.class);
intent.putExtras("TotalMatchSticks", value);
startActivity(intent);