diff --git a/app/src/main/java/com/example/android/android_me/ui/MainActivity.java b/app/src/main/java/com/example/android/android_me/ui/MainActivity.java index 502393c87..fbb3da58b 100755 --- a/app/src/main/java/com/example/android/android_me/ui/MainActivity.java +++ b/app/src/main/java/com/example/android/android_me/ui/MainActivity.java @@ -41,6 +41,28 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + Button nextButton = (Button) findViewById(R.id.next_button); + + // The "Next" button launches a new AndroidMeActivity + // added in oncreate itself so that even when no image is selected and next but is clicked the action performed with default value + nextButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + // Put this information in a Bundle and attach it to an Intent that will launch an AndroidMeActivity + Bundle b = new Bundle(); + b.putInt("headIndex", headIndex); + b.putInt("bodyIndex", bodyIndex); + b.putInt("legIndex", legIndex); + + // Attach the Bundle to an intent + final Intent intent = new Intent(this, AndroidMeActivity.class); + intent.putExtras(b); + + startActivity(intent); + + } + }); + } // Define the behavior for onImageSelected @@ -68,26 +90,6 @@ public void onImageSelected(int position) { break; default: break; } - - // Put this information in a Bundle and attach it to an Intent that will launch an AndroidMeActivity - Bundle b = new Bundle(); - b.putInt("headIndex", headIndex); - b.putInt("bodyIndex", bodyIndex); - b.putInt("legIndex", legIndex); - - // Attach the Bundle to an intent - final Intent intent = new Intent(this, AndroidMeActivity.class); - intent.putExtras(b); - - // The "Next" button launches a new AndroidMeActivity - Button nextButton = (Button) findViewById(R.id.next_button); - nextButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - startActivity(intent); - } - }); - } }