• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps White screen.

hfdjw

Newbie
When I start the app on my emulator i get only white screen and nothing other.
Where is the problem?
[HIGH]package com.example.soslocksmith;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("fgew");
setContentView(R.layout.activity_main);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}

setContentView(R.layout.calllayout);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}
[/HIGH]
activity_main.xml:
[HIGH]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
tools:context=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="176dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>[/HIGH]
 
on the screen you see the layout from calllayout.xml. not activity_main.xml. The first setContentView has no effect. Also the sleep is pointless here. The view is shown after onCreate and it is the one from the last setContentView call.
 
Back
Top Bottom