bluestunt
bluestunt

Reputation: 479

New Intent not Starting on button click

On the app I am making, on the home menu screen that you get to after the splash screen, when you click one of the buttons, nothing happens. I don't know what the problem is?

Here is the src file, it implements View.OnClickListener:

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.bPlay:
        Intent ourIntentPlay = new Intent(PartyActivity.this, Play.class);
        startActivity(ourIntentPlay);
        break;
    case R.id.bFacts:
        Intent ourIntentFacts = new Intent(PartyActivity.this, Facts.class);
        startActivity(ourIntentFacts);  
        break;
    case R.id.bInfo:
        Intent ourIntentInfo = new Intent(PartyActivity.this, Info.class);
        startActivity(ourIntentInfo);   
        break;
    case R.id.bHelp:    
        Intent ourIntentHelp = new Intent(PartyActivity.this, Help.class);
        startActivity(ourIntentHelp);
        break;
    }
}

And here is the manifest, inside the application tags:

<activity
        android:name=".Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".PartyActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="w.m.PARTYACTIVITY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Info"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="w.m.INFO" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Play"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="w.m.PLAY" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name=".Help"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="w.m.HELP" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Thanks

Upvotes: 0

Views: 431

Answers (1)

Jason Robinson
Jason Robinson

Reputation: 31283

Are you assigning a listener to your buttons? Do this in your onCreate() method:

findViewById(R.id.bPlay).setOnClickListener(clickListener);

If your activity implements OnClickListener, then clickListener will be this. Do this for all of your buttons.

Upvotes: 3

Related Questions