开发者

Android problem with opening a second activity and fails to launch

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);
          开发者_StackOverflow社区  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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜