开发者

Android execution error in AVD

an anyone look at this simple code (?) and tell me what's wrong please? I'm a complete beginner to android development and I don't understand why my application doesn't even start. I get an unexpected error.. : ( Here it is:

package applicationTest.ppr.com;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
public class MainClass extends Activity {
    /** Called when the activity is first created. */

    /*Global vars*/
    public static LinearLayout lila;

    @Override
    public void onCreate(Bundle savedInstanceState) {       
        super.onCreate(savedInstanceState);
        lila = (LinearLayout) findViewById(R.id.lilay);
        setContentView(lila);
    }

    public void Shortoast(){new Game(this);}

    public static LinearLayout returnLayout(){return lila;}


}

The program doesn't e开发者_Go百科ven launch, and I think it might have something to do with how I handle the LinearLayout and setContentView();

anyway thanks very much in advance!


Suggestion: keep it as simple as possible until you fix the issue! Then you can concentrate on your business logic.

package applicationTest.ppr.com;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

public class MainClass extends Activity {
    /** Called when the activity is first created. */

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

}

Also, is your main activity mapped in the Android manifest?

<application android:icon="@drawable/icon" android:label="@string/app_name">

    <activity android:name="MainClass"
              android:label="@string/app_name">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

</application>

</activity>

--EDIT-- Do you have the lilay.xml file in your res/layout folder?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜