简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM