enter code here


  <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.newuser.applicationtwo">

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"

    android:roundIcon="@mipmap/ic_launcher_round"
    android:screenOrientation="landscape"
    android:supportsRtl="true"
   >
    <activity

        android:name=".MainActivity"
       android:screenOrientation="landscape"
    android:theme="@style/AppTheme"
        android:label="@string/app_name">
    </activity>
    <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </application>
    <activity android:name=".SecondActivity" />
    <activity android:name=".ThirdActivity" />
    <activity android:name=".FourthActivity" />
    <activity android:name=".FifthActivity" />
    <activity android:name=".SixthActivity" />
    </manifest>



    -----------------------------------------------------------------------


   package com.example.newuser.applicationtwo;

    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.util.Log;
    import android.view.View;
    import android.widget.ImageButton;
    import static android.content.ContentValues.TAG;

  public class MainActivity extends Activity implements View.OnClickListener
{

  private ImageButton playBtn, multiplayerBtn, settingsBtn;

  public MainActivity(ImageButton playBtn, ImageButton multiplayerBtn) {
    this.playBtn = playBtn;
    this.multiplayerBtn = multiplayerBtn;
  }


  @Override
  public void onClick(View v) {
    switch (v.getId()) {


        case R.id.playBtn:
            Intent i = new Intent(getApplicationContext(),
    SecondActivity.class);

            startActivity(i);
            onClick(playBtn);
            Log.d(TAG, "Play Button Move");

            break;

        case R.id.TopicBtn8:
            Intent j = new Intent(getApplicationContext(),
  ThirdActivity.class);

            startActivity(j);
            onClick(multiplayerBtn);
            Log.d(TAG, "Multiplayer Button Move");

            break;
        case R.id.settingsBtn:
            Intent k = new Intent(getApplicationContext(),
    SixthActivity.class);

            startActivity(k);
            onClick(settingsBtn);
            Log.d(TAG, "Settings Button Move");

            break;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    playBtn = (ImageButton) findViewById(R.id.playBtn);
    multiplayerBtn = (ImageButton) findViewById(R.id.multiplayerBtn);
    settingsBtn = (ImageButton) findViewById(R.id.settingsBtn);

    playBtn.setOnClickListener(MainActivity.this);
    multiplayerBtn.setOnClickListener(MainActivity.this);
    settingsBtn.setOnClickListener(MainActivity.this);



   ------------------------------------------------------------------------


   package com.example.newuser.applicationtwo;

 import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.v7.app.AppCompatActivity;
 import android.util.Log;
 import android.view.View;
 import android.widget.Button;

  import static android.content.ContentValues.TAG;

  class SecondActivity extends AppCompatActivity implements
   View.OnClickListener {

 private Button topic1Btn, topic2Btn, topic3Btn, topic4Btn, topic5Btn,
 topic6Btn, topic7Btn, topic8Btn;

 public SecondActivity(Button topic1Btn, Button topic2Btn, Button topic3Btn,
  Button topic4Btn,
                      Button topic5Btn, Button topic6Btn, Button topic7Btn,
   Button topic8Btn) {
    this.topic1Btn = topic1Btn;
    this.topic2Btn = topic2Btn;
    this.topic3Btn = topic3Btn;
    this.topic4Btn = topic4Btn;
    this.topic5Btn = topic5Btn;
    this.topic6Btn = topic6Btn;
    this.topic7Btn = topic7Btn;
    this.topic8Btn = topic8Btn;

  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {


        case R.id.topic1Btn:
            Intent i = new Intent(getApplicationContext(),
  SixthActivity.class);

            startActivity(i);
            onClick(topic1Btn);
            Log.d(TAG, "Topic 1 Button Clicked");

            break;

        case R.id.topic2Btn:
            Intent j = new Intent(getApplicationContext(),
   SixthActivity.class);

            startActivity(j);
            onClick(topic2Btn);
            Log.d(TAG, "Topic 2 Button Clicked");

            break;
        case R.id.topic3Btn:
            Intent k = new Intent(getApplicationContext(),
    SixthActivity.class);

            startActivity(k);
            onClick(topic3Btn);
            Log.d(TAG, "Topic 3 Button Move");

            break;

        case R.id.topic4Btn:
            Intent l = new Intent(getApplicationContext(),
   SixthActivity.class);

            startActivity(l);
            onClick(topic4Btn);
            Log.d(TAG, "Topic 4 Button Move");

            break;
        case R.id.topic5Btn:
            Intent m = new Intent(getApplicationContext(),
    SixthActivity.class);

            startActivity(m);
            onClick(topic5Btn);
            Log.d(TAG, "Topic 5 Button Clicked");

            break;

        case R.id.topic6Btn:
            Intent n = new Intent(getApplicationContext(),
    SixthActivity.class);
            startActivity(n);
            onClick(topic6Btn);
            Log.d(TAG, "Topic 6 Button Clicked");

            break;
        case R.id.topic7Btn:
            Intent o = new Intent(getApplicationContext(),
    SixthActivity.class);

            startActivity(o);
            onClick(topic7Btn);
            Log.d(TAG, "Topic 7 Button Move");

            break;

        case R.id.topic8Btn:
            Intent p = new Intent(getApplicationContext(),
     SixthActivity.class);

            startActivity(p);
            onClick(topic8Btn);
            Log.d(TAG, "Topic 8 Button Move");

            break;
    }
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);

    topic1Btn = (Button) findViewById(R.id.topic1Btn);
    topic2Btn = (Button) findViewById(R.id.topic2Btn);
    topic3Btn = (Button) findViewById(R.id.topic3Btn);
    topic4Btn = (Button) findViewById(R.id.topic4Btn);
    topic5Btn = (Button) findViewById(R.id.topic5Btn);
    topic6Btn = (Button) findViewById(R.id.topic6Btn);
    topic7Btn = (Button) findViewById(R.id.topic7Btn);
    topic8Btn = (Button) findViewById(R.id.topic8Btn);

    topic1Btn.setOnClickListener(SecondActivity.this);
    topic2Btn.setOnClickListener(SecondActivity.this);
    topic3Btn.setOnClickListener(SecondActivity.this);
    topic4Btn.setOnClickListener(SecondActivity.this);
    topic5Btn.setOnClickListener(SecondActivity.this);
    topic6Btn.setOnClickListener(SecondActivity.this);
    topic7Btn.setOnClickListener(SecondActivity.this);
    topic8Btn.setOnClickListener(SecondActivity.this);


    Intent intent = new Intent(getApplicationContext(),
  SixthActivity.class);

    startActivity(intent);
  }
  }

----------------------------------------------------


我想知道是否有人可以提供帮助?我正在尝试构建测验应用程序,而我
清单文件中的主要活动有问题。它似乎
要求构造函数,当我运行代码时,它告诉我
following:运行SecondActivity时出错:活动“ SecondActivity”为
未在AndroidManifest.xml中声明。不确定如何将其更改为
不幸的是MainActivity或为SecondActivity添加的其他内容
通过阅读有关MainActivity的类似问题,我无法解决它。

我附加清单文件以及MainActivity和SecondActivity

最佳答案

移动

</application>*


就在之前

</manifest>


因为现在只有第一个活动在范围内

关于java - 主要 Activity 要求构造函数-第二个 Activity 不在 list 文件中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44605930/

10-10 08:35