Android problem with opening a second activity and fails to launch

Posted by Capsud on Stack Overflow See other posts from Stack Overflow or by Capsud
Published on 2010-04-12T14:49:15Z Indexed on 2010/04/12 14:53 UTC
Read the original article Hit count: 251

Filed under:
|

Hi there, Bear with me as i'm just learning about Android. What i'm trying to do is to open an Activity when i click on a button. This is my code in my main activity

public class MainPage extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button restaurants = (Button) findViewById(R.id.widget88);
    restaurants.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), AZRestaurants.class);
            startActivityForResult(myIntent, 0);               
        }

    });

    //Button location = (Button) findViewById(R.id.location);
    //location.setOnClickListener(new View.OnClickListener() {
        //public void onClick(View view) {
        //  Intent myIntent = new Intent(view.getContext(), Location.class);
        //  startActivity(myIntent);
        //}
  //  });
}

The program launches no problem when i just implement the first button (restuarant).

But when i try to implement the button that i have commented out it fails to launch. and yes i have added the activity to the manifest file.

Can anyone help me please?

Thanks.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-manifest