- Forum-Beiträge: 5
21.07.2015, 13:06:29 via Website
21.07.2015 13:06:29 via Website
Hey, I am totally confused, I wanted to create a new App and set the OnClickListener for starting the next Activity, before I've done this my App worked. It started the Main Activity, showed everything.
Now If I'm trying to run my App I get spammed with several Messages in the logcat and it don't stop until I unplug my Phone and the App doesn't even start. There comes only a message ''Royal Trainer wurde angehalten" (Royal Trainer was stopped).
I checked my code, it isn't long yet, so I thought I can find the mistake easyily but I can't find it.
I'll post my MainActivity.java
package royalarmyorg.de.royalquiz;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;public class MainActivity extends Activity {
ImageButton StartButton = (ImageButton) findViewById(R.id.StartButton); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, QuizActivity.class); startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.