android - Take screenshot method inside Fragment -


I'm trying to work this code inside a piece. This code runs fine inside an activity, but I can not do it to work inside the piece.

When I click on a button, this tells the Lecturanshot method.

Code for this screenshot:

  Public Bitmap LaserSot () {see Routview = AddressWebID (android.R.id.content) .getRootView (); RootView.setDrawingCacheEnabled (true); Return rootView.getDrawingCache (); }   

Due to being in this one piece "findViewById" has not been identified.

I have tried:

  View root view = GetView (). FindViewById (android.R.id.content) .getRootView ();   

But this is not working either I got

  07-25 09: 37: 32.746: E / Android Random (31221): surplus exception: the main 07-25 09: 37: 32.746: e / Android Rentaim (31221): Java lang.NullPointerException 07-25 Sept: 37: 32.746: e / AndroidRuntime (31,221): 37 :: 32.746: e / AndroidRuntime com .dream3ncore.thefinalwordcounts.level01.Song01.takeScreenshot (Song01.java:763) 07-25 September (31,221): 37 :: 32.746: e / AndroidRuntime (31,221): to AndroidkviewkViewkperformClick (see com. Dream3ncore.thefinalwordcounts.level01.Song01.onClick (Song01.java:152) in 07-25 September .Java: 4211) 07-25 09: 37: 32.746: E / Android Random (31221): On Android. View.View $ PerformClick.run (see. Java 17362) 07-25 09: 37: 32.746: E / Androindertime (31,221): android.os.Handler.handleCallback (Handler.java:725) on 07-25 September: 37 : 32.746: E / AndroidRuntime (31,221): android.os.Handler.dispatchMessage (on Handler.java:92) 07 -25 09: 37: 32.746: E / Android Random (31221): Android. Los. Looper Loop (Looper.java:137) 07-25 09: 37: 32.746: E / Androidrentaim (31221): .ActivityThread.main on Android.ap (ActivityThread.java: 5227) 07-25 09: 37: 32.746: E / Android Rentaim (31221): java.lang.reflect.Method.invokeNative (the original method) 07-25 09: 37: 32.746: e / Androidrentaim (31,221) on java.lang.reflect.Method.invoke (Method.java 511) 07-25 Sept: 37: 32.746: e / AndroidRuntime (31,221): com.android.internal.os.ZygoteInit at $ MethodAndArgsCaller.run (ZygoteInit.java: 795) 07-25 Sept: 37: 32.746: e / AndroidRuntime (31,221): 37 :: 32.746: e / AndroidRuntime com.android.internal.os.ZygoteInit.main (ZygoteInit.java:562) 07-25 September (31221): Dalvik.system.NativeStart.main on ( Basic method)   

Any help too much Will be living

your piece of UI your activity There is a subset of getView () in a section will only return your view hierarchy to just getView () to Alternatively, I believe you can call getView () to getActivity () , and it will work. Avoid the look of GetRootView () and android.R.id.content in the first place.

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -