Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBoipelo Phologolo
4,505 Pointscreating an app and I am stuck at the last part where i have to retrieve text for all my pages, please help
public class TypeActivity extends AppCompatActivity { private Type type; private ImageView typeImageView; private TextView typeTextView; private Button option1Button; private Button option2Button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_type);
typeImageView = (ImageView) findViewById(R.id.typeImageView);
typeTextView = (TextView) findViewById(R.id.typeTextView);
option1Button = (Button) findViewById(R.id.option1Button);
option2Button = (Button) findViewById(R.id.option2Button);
Intent intent = getIntent();
type = new Type();
loadpage(0);
} private void loadpage(int pageNumber) { Page page = type.getPage(pageNumber);
Drawable image = ContextCompat.getDrawable(this, page.getImageId());
typeImageView.setImageDrawable(image);
String pageText = getString(page.getTextId());
typeTextView.setText(pageText);
option1Button.setText(page.getOption1().getTextId());
option2Button.setText(page.getOption2().getTextId());