hardartcore
hardartcore

Reputation: 17037

Ui elements in xml doesn't show up in emulator?

Here is the problem.My UI elements in xml doesn't show up when i run my app in emulator.

public void OnCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.single_coll);

        Button one = (Button) findViewById(R.id.all_stampii);
        one.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), AllStampii.class);
                startActivity(intent);
            }

        });}

single_coll.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

    <Button android:text="All Stampii" android:id="@+id/all_stampii" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    <Button android:text="Owned" android:id="@+id/owned" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    <Button android:text="Repeated" android:id="@+id/repeated" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    <Button android:text="Last Acquired" android:id="@+id/last_ac" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>

There are no errors. I just can't see the Ui elements in emulator, in only this class. Any suggestions?

Upvotes: 0

Views: 1014

Answers (2)

kuxi
kuxi

Reputation: 123

You don't seem to be overriding the onCreate method. That means that the OnCreate method you've got there is not being called on startup. If you change the first line to

@Override
public void onCreate(Bundle savedInstance){

(note the lower-case 'o' in onCreate) then the method will be called correctly

Upvotes: 2

Khawar
Khawar

Reputation: 5227

I think you are having a minor problem in function declaration. What you have is:

public void OnCreate(Bundle savedInstanceState)

Make the 'OnCreate' to 'onCreate' and put @Override before the declaration.

Upvotes: 2

Related Questions