Open a new screen in Android?

Hi, I am new to android. In my application, if the user selects a button in alertDialog, I need to open a new screen, and I need to display some message on this screen. How to open a new screen?

+4
source share
4 answers

You open a new action (for example, a screen), creating and removing a new intention:

Intent intent = new Intent(this, YourNewActivity.class) startActivity(intent) 
+7
source

comment on Erich Douglass's post: and don't forget to describe it in AndroidManifest.xml, for example

 <activity android:name=".YourNewActivity" android:label="@string/app_name" /> 
+4
source

Is this line added inside the manipulator button method of the warning dialog box?

 setContentView(R.layout.screenx); 
0
source

Try it out,

 Button btt1 = (Button) findViewById(R.id.button1); btt1.setOnClickListener( View.OnClickListener() { public void onClick(View arg0) { //Starting a Intent Intent next= Intent(getApplicationContext(), second.class); startActivity(next); } }); 

You should create btt1.setOnClickListener (View.OnClickListener () {

  public void onClick(View arg0) { //Starting a Intent Intent next= Intent(getApplicationContext(), pack_detail.class); startActivity(next); } }); 

the second java file looks like

 public class second extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.secondx); } } 

and you should create a secondx.xml file, and remember to add the expression below in the manifest

 <activity :name=".second"> </activity> 

good luck ...

0
source

Source: https://habr.com/ru/post/1310852/


All Articles