当我打开应用程序时,它会突然停止,我不知道为什么。有人可以通过查看代码帮助我,并告诉我我做错了什么。非常感谢。
Button buttonCommand;
Button tiltCommand;
Button vocalCommand;
Button instructions;
Button about;
Button arduino; // Links Button
Button android; // Links Button
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
buttonCommand = (Button)findViewById(R.id.buttons);
tiltCommand = (Button)findViewById(R.id.tilt);
vocalCommand = (Button)findViewById(R.id.vocal);
instructions = (Button)findViewById(R.id.instructions);
about = (Button)findViewById(R.id.about);
arduino = (Button)findViewById(R.id.arduino);
android = (Button)findViewById(R.id.android);
}
public void onClickButton(View view){
Intent i = new Intent(getApplicationContext(),ButtonCommand.class); // ButtonCommand Activity
startActivity(i);
}
public void onClickTilt(View view){
Intent i = new Intent(getApplicationContext(),TiltCommand.class); // TiltCommand Activity
startActivity(i);
}
public void onClickVocal(View view){
Intent i = new Intent(getApplicationContext(),VocalCommand.class); // VocalCommand Activity
startActivity(i);
}
public void onClickInstructions(View view){
Intent i = new Intent(getApplicationContext(),Instructions.class); // Instructions Activity
startActivity(i);
}
public void onClickAbout(View view){
Intent i = new Intent(getApplicationContext(),About.class); // About Activity
startActivity(i);
}
public void onClickArduino(View view){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://forum.arduino.cc/"));
startActivity(intent);
}
public void onClickAndroid(View view){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://forum.xda-developers.com/"));
startActivity(intent);
}
答案 0 :(得分:0)
如果您的应用在开始时停止,可能您错过了将您的活动注册表添加到[[RMStore defaultStore] restoreTransactionsOnSuccess:^(NSArray* transactions)
{
NSLocale* dateLocale = [NSLocale autoupdatingCurrentLocale];
for (SKPaymentTransaction* t in transactions)
NSLog(@"%@", [t.transactionDate descriptionWithLocale: dateLocale]);
}
failure:^(NSError* error)
{
}];
:
AndroidManifest.xml
George,您需要为每个按钮创建一个OnClickListener,例如:
<activity android:name=".ButtonCommand" />
<activity android:name=".TiltCommand" />
<activity android:name=".VocalCommand" />
<activity android:name=".Instructions" />
<activity android:name=".About" />
Plus:以及开放网址的互联网许可:
buttonCommand = (Button)findViewById(R.id.buttons);
buttonCommand.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),ButtonCommand.class); // ButtonCommand Activity
startActivity(i);
}
});