android - setOnClickListener of a ListView not working -


Then trying to set a setOnClickListener for my list view, but due to this crash in my program for some reason I try because I am. I am quite new to programming, when it comes to troubleshooting, then I can really talk about anything sad: (My code is down so there can be any wrong idea that Will be very useful

  are public classes Expanding activity of the OmPackage activity {// List view that holds the list ListView lstTest; // Array adapter, which holds ArrayList and displays items on the ListView AlertsAdapter array adapter; // list items which are ArrayList & amp; alerts & amp; gt; alrts = null; /. setContentView (R.layout.homepage), ** called when the activity went previously created * / @Override void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState) protected // Start ListView lstTest = (ListView) findViewById (R.id.lstText); // I ArrayList alrts = Start new ArrayList & amp; Lt; Alert & amp; Gt; (); // Start the array adapter array = adapter = new alert adapter (homepage, etc., R. Latest Listings, Artwork); // Set up the above adapter as an adapter of choice for our list lstTest.setAdapter (arrayAdapter); LstTest.setOnClickListener (new View.OnClickListener () {public void onClick (see v) {intent = new intent (homepage promotion.This, promotion activity class); startActivity (intent);}}); // ... ... ...}}  

Any thoughts? Im stuck: (

Edit: Posting error log file from ddms

08-04 04: 14: 26.351: error / Android randomime (8882): fatal exception: main 08 -04 04: 14: 26.351: error / AndroidRuntime (8882): java.lang.RuntimeException: unable to start activity ComponentInfo {hypenyte.bdutcher.promopost / hypenyte.bdutcher.promopost.HomePageActivity}: java.lang.RuntimeException : do not call for a AdapterView setOnClickListener you probably want setOnItemClickListener instead 08-04 04 :. 14: 26.351: 08-04 error / AndroidRuntime (8882): android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2663) 04:14: 26.351: Error / AndroidRuntime (8882): android.app.Activity Thread.handleLaunchActivity (ActivityThread.java:2679) 08-04 04: 14: 26.351: Error / AndroidRuntime (8882): android.app.ActivityThread.access $ 2300 (ActivityThread.java:12225) 08-04 04: 14: 26.351: Error / Android Runtime (8882): Android.App ActivityTV $ H Holland Message (ActivityTrad.Java 2033) 08-04 04: 14: 26.351: Error / AndroidRun Time (8882): Android.OS. Handler Dispatch Message (Handler. Java: 99) 08-04 04: 14: 26.351: Error / Android Time (8882): Android.OS Lopper Lope (Looper.Java 233)) 08-04 04: 14: 26.351: Error / Android Retintman (8882): Android. App Activitat.mein (activityTrad.JYY6627) 08-04 04: 14: 26.351: error / AndroidMantrum (8882): On Java. Lang.reflect.Method.invokeNative (Basic Method) 08-04 04: 14: 26.351: Error / Android Random (8882): at java.lang.reflect.Method.invoke (method java 121) 08-04 04: 14 : 26.351: error / AndroidRuntime (8882): on com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:868) 08-04 04: 14: 26.351: error / AndroidRuntime (8882): com. Android.internal.os.ZygoteInit.main (ZygoteInit.java:626) 08-04 04: 14: 26.351: Error / AndroidRuntime (8882): dalvik.system.NativeStart.main (Native Method) 08-04 04: 14: 26.351: Error / Android Runtime (8882): Reason by: java.lang.RuntimeException: Do not call setOnClickListener for an Adapter View. You probably want setOnItemClickListener instead 08-04 04: 14: 26.351: Error / AndroidRuntime (8882): 14: 26.351: android.widget.AdapterView.setOnClickListener (AdapterView.java:750) Error 08-04 04 / AndroidRuntime (8882) : 14: 26.351: error / AndroidRuntime (8882): hypenyte.bdutcher.promopost.HomePageActivity.onCreate (HomePageActivity.java:58) on android.app.Instrumentation.callActivityOnCreate at 08-04 04 (Instrumentation.java:1047) 08- 04 04: 14: 26.351: Error / Android Random (8882): Android. App ActivatedTrade.Perform Launching Activity (ActivityTrad.Azawakia 627) 08-04 04: 14: 26.351: Error / Andorrentime (8882): ... 11 and

I have seen it that I Probably want to setOnItemClickListener which was originally coded as I did it but since Eclipse told me my code was wrong with it it wouldnt work that

You need to use setOnItemClickListener ()

and then new android.widget.AdapterView.On I TemClickListener ()

No New View.OnItemClickListener ()


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -