Thursday 15 September 2011

java - Android: This imageView is not found? -


I am loading a bitmap from the input stream and putting it on an image view. So I have a button which should draw a circle on bitmap. The error is that imageview (which is called 'touch') is not found inside onClickListener ... how can I fix it? When I press the button, then nothing happens. (Note: Zoom Injhumot square, is an extension of Imejyuwu)

  to try {java.io.FileInputStream = this.openFileInput (path); Bitmap bitmap = bitmapfenderDecodedStream (in); Find ZoomInZoomOut Touch = (Zoom InZoom) VVBIID (RID. IMJIIDID); Touch = arrangeImageView (touch); Touch.setImageBitmap (bitmap); In.close (); Draw Button = (Button) Find ViewById (R.id.draw); draw.setOnClickListener (New View.OnClickListener () {public void onClick (View v) {bitmap imageBitmap = Bitmap.createBitmap (200, 200, Bitmap.Config.ARGB_8888); canvas = new Canvas (imageBitmap); painted p = new Paint (); p.setAntiAlias ​​(true); p.setColor (Color.BLUE); canvas.drawCircle (60, 50, 25, P); /////////////// // ///// Error is on the next line: touch.setImageBitmap (imageBitmap);}}); } Hold (exception e) {e.printStackTrace (); }  

Here is XML:

  & lt; RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: device = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: layout_height = "Match_parent" Android: paddingLeft = "@ Dimen / activity_horizontal_margin" Android: paddingRight = "@ Dimen / activity_horizontal_margin" Android: paddingTop = "@ Dimen / activity_vertical_margin" Android: paddingBottom = "@ Dimen / activity_vertical_margin" Android: background = "@ drawable / Background "tool: reference =" com.commonsware.android.test1.ImageDisplayActivity "& gt; & Lt; Com: com.commonsware.android.test1.ZoomInZoomOut Android: id = "@ + id / IMAGEID" Android: layout_width = "match_parent" android: layout_height = "match_parent" android: layout_alignParentTop = "true" Android: layout_alignParentLeft = "true" Android: Layout_alignParentStart = "true" /> Android: Layout_height = "Wrap_content" android: text = "O" android: id = "@ + id / Draw" Android: Leaut_aling ParentBottom = "Android buttons" true "Android: Leaut_liinprarthlft =" true "Android: Leaut_algin Parentstart =" True "/>  

touch variable one If you want more explanation, then check it out.

In order to correct your problem, Change your code:

  Last zoom in Jhumot touch = (zoom Injhumot) Dundenwubiaiaidi (R.id.IMAGEID);  

or < / Strong> You can also create a variable in your class if you can get it later from the second scope:

  touch the private zoom inzoomout;  

and thus illustration:

  touch = (ZoomInZoomOut) findViewById (R.id.IMAGEID);  

No comments:

Post a Comment