It is probably better to parse the data first. However, everything else must come after setting the content view, as the view will not be in focus and the R.id variables will be invalid.