LongClickable

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

LongClickable

Postby trainstroker » Fri Jan 08, 2010 4:29 am

I have a gallery and it works fine up until i try to make the individual pictures LongClickable. Please help.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. i.setOnLongClickListener(new View.OnLongClickListener() {
  2.  
  3.                         public boolean onLongClick(View v){
  4.  
  5.                                 ImageView full = new ImageView(mContext);
  6.  
  7.                                
  8.  
  9.                                 full.setImageBitmap(mImages.get(0));
  10.  
  11.                                 full.setMaxHeight(20);
  12.  
  13.                                 setContentView(full);
  14.  
  15.                                
  16.  
  17.                                 Log.v("TAG","CHECK");
  18.  
  19.                                 return true;
  20.  
  21.                                
  22.  
  23.                         }
  24.  
  25.                 });
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


I get this error message after I try to longclick (also touch scrolling seems nonresponsive)


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. 01-07 22:25:37.613: VERBOSE/TAG(12288): CHECK
  2.  
  3. 01-07 22:25:37.972: DEBUG/AndroidRuntime(12288): Shutting down VM
  4.  
  5. 01-07 22:25:37.972: WARN/dalvikvm(12288): threadid=3: thread exiting with uncaught exception (group=0x4001b180)
  6.  
  7. 01-07 22:25:37.988: ERROR/AndroidRuntime(12288): Uncaught handler: thread main exiting due to uncaught exception
  8.  
  9. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288): java.lang.NullPointerException
  10.  
  11. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.widget.Gallery.onScroll(Gallery.java:911)
  12.  
  13. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.view.GestureDetector.onTouchEvent(GestureDetector.java:490)
  14.  
  15. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.widget.Gallery.onTouchEvent(Gallery.java:839)
  16.  
  17. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.view.View.dispatchTouchEvent(View.java:3709)
  18.  
  19. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:851)
  20.  
  21. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
  22.  
  23. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
  24.  
  25. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
  26.  
  27. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
  28.  
  29. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
  30.  
  31. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
  32.  
  33. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
  34.  
  35. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.os.Handler.dispatchMessage(Handler.java:99)
  36.  
  37. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.os.Looper.loop(Looper.java:123)
  38.  
  39. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at android.app.ActivityThread.main(ActivityThread.java:4338)
  40.  
  41. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at java.lang.reflect.Method.invokeNative(Native Method)
  42.  
  43. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at java.lang.reflect.Method.invoke(Method.java:521)
  44.  
  45. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  46.  
  47. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  48.  
  49. 01-07 22:25:38.269: ERROR/AndroidRuntime(12288):     at dalvik.system.NativeStart.main(Native Method)
  50.  
  51.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
trainstroker
Freshman
Freshman
 
Posts: 3
Joined: Tue Nov 17, 2009 6:04 am

Top

Re: LongClickable

Postby jagtap.jj1 » Mon Jan 11, 2010 9:21 am

Do not use setContentView(), directly inside OnLongClickListener(),
Use like this mContext.setContentView(full);
OR
MyActivity.this.setContentView(full); (Where MyActivity is activity name for which r u showing setContentView())

java-android developer
User avatar
jagtap.jj1
Senior Developer
Senior Developer
 
Posts: 124
Joined: Fri Aug 22, 2008 11:52 am
Location: India(Mumbai)

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests