views:

58

answers:

2

I have a basic calculator app I'm making. Two activities, the main one and ResultView.

I've made it where I click a button on activity A to go to activity B. The log says activity B is started and "displayed" successfully, the title for the new activity loads, but the body does NOT show. I added a simple Text view with static text.. see the result.xml at the bottom. I also tried inserting information programmatically, but that didn't do.

When I debug the program, I tried putting breakpoints as the activity is called with startActivity() as well as on the first line of the onCreate method within the ResultView class (my activity "B") but the program never hits the second breakpoint. In fact, it looks as if Looper.class is called in the end.

This bit of code is placed in the button handler on acitivity A:

i.putExtra("test1",34);

i.putExtra("test2",35);

this.startActivity(i);

This in the onCreate function in activity B:

public void OnCreate(Bundle
      savedInstanceState){

      super.onCreate(savedInstanceState);

      setContentView(R.layout.result);

}

The activity is in the manifest, within the "application" tag:

<activity
android:name="ResultView"></activity>

If I didn't supply enough info, let me know.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llParent"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="HELLO WORLD"
    /> </LinearLayout>

If more info is needed, let me know...in short, "HELLO WORLD" does not display at all.

+1  A: 

Are you sure that the public void line or the line before that contains @Override? If not, you're not overriding the OnCreate method. The code should read

@Override public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.result);
}

EDIT
Of course the "O" must not be a capital "O"...

Thorsten Dittmar
+2  A: 

It's not OnCreate, it's onCreate (lowercase o). Otherwise the method won't be overriden. The @override annotation has no effect if it's omitted, it's just for readability for the programmer.

JRL
+1 You're right of course - he's not even overriding the method. I always thought Java would not accept and compile uppercase method names?
Thorsten Dittmar
Awesome, I knew you guys could help a newbie out. I'd reward points, but I'm not a registered member.
Brandon