Android Build an Interactive Story App The Rest of the Story Loading Additional Pages

Cannot find .getNextPage

package com.example.interactivestory.ui;

import android.content.Context; import android.content.Intent; import; import; import; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView;

import com.example.interactivestory.R; import com.example.interactivestory.model.Page; import com.example.interactivestory.model.Story;

public class StoryActivity extends AppCompatActivity {

public static final String TAG = StoryActivity.class.getSimpleName();

private String name;
private Story story;
private ImageView storyImageView;
private TextView storyTextView;
private Button choice1Button;
private Button choice2Button;

protected void onCreate(Bundle savedInstanceState) {

    storyImageView = (ImageView)findViewById(;
    storyTextView = (TextView)findViewById(;
    choice1Button = (Button)findViewById(;
    choice2Button = (Button)findViewById(;

    Intent intent = getIntent();
    name = intent.getStringExtra(getString(R.string.key_name));
    if (name == null || name.isEmpty()) {
        name = "Friend";
    Log.d(TAG, name);

    story = new Story();


private void loadPage(int pageNumber) {
    final Page page = story.getPage(pageNumber);

    Drawable image = ContextCompat.getDrawable(this, page.getImageId());

    String pageText = getString(page.getTextId());
    // add name is placeholder include. Wont add if not

    pageText = String.format(pageText, name);

    choice1Button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            int nextPage = page.getChoice1().get;


1 Answer

Hi Evan. Maybe you've solved it since then, but in case you haven't , just check the onClick() method at the bottom of your class. You wrote:

int nextPage = page.getChoice1().get;

instead of

int nextPage = page.getChoice1().getNextPage();

Hope that helps :)