-1

My code works until I add line 7 in, at which point it crashes.

    private void registerClickCallback() {
        ListView list = (ListView) findViewById(R.id.listview);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    startActivity(new Intent(getApplicationContext(), ResourcesArea.class));
                }
            }
        });
    }

Could someone give me an idea of where to look to find out what's going wrong? I have only just started with the ADT and I am not sure how to find out what's making it crash.

This is the logcat error messages:

07-30 13:52:00.483: E/AndroidRuntime(1099): FATAL EXCEPTION: main
07-30 13:52:00.483: E/AndroidRuntime(1099): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at org.thetutortrust.tutortrust.ResourcesArea.onCreate(ResourcesArea.java:16)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.Activity.performCreate(Activity.java:4538)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2240)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.access$600(ActivityThread.java:139)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.os.Looper.loop(Looper.java:156)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at android.app.ActivityThread.main(ActivityThread.java:4987)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at java.lang.reflect.Method.invokeNative(Native Method)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at java.lang.reflect.Method.invoke(Method.java:511)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-30 13:52:00.483: E/AndroidRuntime(1099):     at dalvik.system.NativeStart.main(Native Method)
Jamie Twells
  • 1,924
  • 4
  • 26
  • 56

2 Answers2

0

once check whether activity added to manifest or not.Put below code in manifest

<activity
        android:name="org.thetutortrust.tutortrust.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
<activity
        android:name="org.thetutortrust.tutortrust.ResourcesArea">
</activity>
sandeepmaaram
  • 4,191
  • 2
  • 37
  • 42
0

I managed to fix it. I'd copied an example for the listview from another site and it had used:

public class MainActivity extends Activity {

but the activity I was going to used:

public class MainActivity extends ActionBarActivity {

so it was crashing. Just changed them to both be ActionBarActivity and added:

import android.support.v7.app.ActionBarActivity;

and it all works now!

Jamie Twells
  • 1,924
  • 4
  • 26
  • 56