Here's the code:
<RelativeLayout android:id="@+id/TextDisplayLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/PrintSetupTextHeight"
android:layout_marginTop="45dp"
android:layout_marginBottom="15dp">
</RelativeLayout>
and
public class MainScreen extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
RelativeLayout infoDisplay = (RelativeLayout) findViewById(R.id.TextDisplayLayout);
TextView sdCardInfo = new TextView(this);
sdCardInfo.setId(1);
sdCardInfo.setText("SD Card Info Here");
sdCardInfo.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, 100));
sdCardInfo.setBackgroundColor(Color.GRAY);
sdCardInfo.setGravity(Gravity.CENTER);
infoDisplay.addView(sdCardInfo);
}
I've narrowed down the problem to
infoDisplay.addView(sdCardInfo);
The app works when this part is commented out, but obviously I need this part of the code. Does anybody know why it's not working?