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 acti开发者_JAVA技巧vity 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);
}
}
I have also added this line in Manifest file:
<activity android:name=".PlayClass" android:label="@string/app_name" />
This NEWAct activity is crashing.And this is the LogCat values:
06-22 12:24:54.392: WARN/dalvikvm(755): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 06-22 12:24:54.442: ERROR/AndroidRuntime(755): FATAL EXCEPTION: main 06-22 12:24:54.442: ERROR/AndroidRuntime(755): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matchsticks/com.matchsticks.PlayClass}:
Hi please use below code.
Intent intent=new Intent(NewAct.this,PlayClass.class);
intent.putExtras("TotalMatchSticks", value);
startActivity(intent);
精彩评论