Wonderful! Thanks a million :)
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mark Murphy
Sent: Tuesday, August 11, 2009 5:59 PM
To: [email protected]
Subject: [android-beginners] Re: Two questions
tinyang wrote:
> Well my problem now is that I am trying to start the SubActivity on
> the button click, but when I run it in the emulator, it does not
> Launch the SubActivity, and I can't figure out why. Here is all of my
code:
>
> public class MainMenu extends Activity {
> /** Called when the activity is first created. */
> Button guidebtn = null;
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main); //xml file that has the layout
needed
> guidebtn = (Button) findViewById(R.id.guide); //find the
> button from the xml layout
> }
> public class guide extends Activity {
> public Button onClick(View guide){
> startActivity(new Intent(this, SubActivity.class));
> return guidebtn;
> };
> }
> }
>
> What am I missing?
I think you need to spend some more time with some tutorials, such as:
http://developer.android.com/guide/tutorials/notepad/index.html
1. You have not connected a View.OnClickListener to your Button
2. Your guide class is unused, and probably should not be there, with your
onClick() implementation being moved to the View.OnClickListener you have
not set up
The Notepad tutorial, linked to above, will demonstrate how to use a Button.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Need help for your Android OSS project? http://wiki.andmob.org/hado
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.13.49/2293 - Release Date: 8/11/2009
6:27 PM
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---