简体   繁体   English

单击按钮后无法启动新意图

[英]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: 这是src文件,它实现了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: 在您的onCreate()方法中执行以下操作:

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

If your activity implements OnClickListener , then clickListener will be this . 如果您的活动实现了OnClickListener ,则clickListener将是this Do this for all of your buttons. 对所有按钮执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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