Hello, Podkuyte what troubles ... In the Main_Activity there are 3 ImageButton and they lead to the call of 3 different Activities. But the problem is that new windows are called spontaneously. Here are a couple of logs where for some reason salati_list instead of lapsha_list

05-22 19:40:07.429 17915-17915/? D/States: MainActivity: onCreate() 05-22 19:40:07.430 17915-17915/? D/States: MainActivity: onStart() 05-22 19:40:07.430 17915-17915/? D/States: MainActivity: onResume() 05-22 19:40:12.389 17915-17915/? D/States: MainActivity: onPause() 05-22 19:40:12.738 17915-17915/? D/States: MainActivity: onCreate() 05-22 19:40:12.754 17915-17915/? D/States: MainActivity: onStart() 05-22 19:40:12.754 17915-17915/? D/States: salati_list: onStart() 05-22 19:40:12.754 17915-17915/? D/States: MainActivity: onResume() 05-22 19:40:12.754 17915-17915/? D/States: salati_list: onResume() 05-22 19:40:13.176 17915-17915/? D/States: MainActivity: onStop ()

 public class MainActivity extends AppCompatActivity implements View.OnClickListener{ ImageButton imageButton_lapsha; ImageButton imageButton_supi; ImageButton imageButton_salati; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageButton_lapsha= (ImageButton) findViewById(R.id.imageButton); imageButton_lapsha.setOnClickListener(this); imageButton_supi= (ImageButton) findViewById(R.id.imageButton2); imageButton_supi.setOnClickListener(this); imageButton_salati= (ImageButton) findViewById(R.id.imageButton3); imageButton_salati.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.imageButton: Intent intent = new Intent(this, lapsha_list.class); startActivity(intent); case R.id.imageButton2: Intent intent2 = new Intent(this, supi_list.class); startActivity(intent2); case R.id.imageButton3: Intent intent3 = new Intent(this, salati_list.class); startActivity(intent3); // TODO Call second activity } } 

}

I will also drop the manifesto, just in case, I don’t know what the problem is. Thank.

  <application android:allowBackup="true" android:icon="@drawable/ic_logo_main" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".lapsha_list"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".supi_list"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".salati_list"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> 

  • one
    I almost didn’t write anything to android and I’m mistaken, but android.intent.action.MAIN means the main activation, that is, the entry point to the application. At startup, it is created first. Perhaps your windows spontaneously appear because of this. android.intent.action.MAIN - UserName
  • Thanks, but the problem was onclin, it was necessary to finish the break. - Romik romikromik

1 answer 1

the problem was onclin, it was necessary to finish the break

 case R.id.imageButton: Intent intent = new Intent(this, lapsha_list.class); startActivity(intent); **break;**