There are lots (and lots) of examples doing this in the samples in the
SDK.  If you want to look at a smallish app have a look at the Notepad
sample.

--
RichardC

On Oct 27, 2:11 pm, Sobert <[email protected]> wrote:
> Hi,
>
> I get a small problem here.
>
> I have a simple App, with two layout (main.xml and credits.xml).
>
> With the onclick on the btnCredits button, I switch from main.xml to
> credit.xml with this code :
>
> public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         final Button btnCredit = (Button) findViewById
> (R.id.BtnCredits);
>         btnCredit.setOnClickListener(new View.OnClickListener() {
>             public void onClick(View v) {
>                 setContentView(R.layout.credit);
>             }
>         });
>     }
>
> I've tried to add the onclick for the back button from the credit
> layout with this :
>
> public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>         final Button btnCredit = (Button) findViewById
> (R.id.BtnCredits);
>         btnCredit.setOnClickListener(new View.OnClickListener() {
>             public void onClick(View v) {
>                 setContentView(R.layout.credit);
>             }
>         });
>         final Button btnBack = (Button) findViewById(R.id.BtnBack);
>         btnBack.setOnClickListener(new View.OnClickListener() {
>             public void onClick(View v) {
>                 setContentView(R.layout.main);
>             }
>         });
>
>     }
>
> It crash pretty well.
> And I must tell, I'm kinda relieved that it's not the right thing to
> do (put all in a single activity).
>
> I've searched the web for a little, and I found "Intent" and
> startActivity() method.
> Is this the right thing to do ? Someone could paste there something
> more simple than the notepad sample (an adaptation for my app would be
> fine), juste two screen, switching from on to another and back ?
>
> Or maybe I'm totally wrong, and it's NOT AT ALL what must be done ?
>
> Thanks, and excuse my poor english ;)
>
> Sylvain.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to