Hi all, So I have an activity which is a Canvas. I wanted to put a button on it. I'm able to do that, but several problems happened : 1) When I want to do button.setText("name"); -> there is a force close of the app, with the following error : NullPointer exception on the line calling the setText() method. BUT if I just do : button.setEnabled(false); there is no problem..
2) When I tried to implements the click on the button, nothing happened and I don't really understand why.. Here is the code I've done : public class MyView extends View implements View.OnClickListener{ .... @Override protected void onDraw(Canvas canvas) { canvas.drawColor(Color.WHITE); canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); canvas.drawPath(mPath, mPaint); undo_Btn.draw(canvas); undo_Btn.setOnClickListener(this); invalidate(); } ...... @Override public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()){ case 1 : Toast.makeText(this.getContext(), "Click", Toast.LENGTH_SHORT).show(); break; } } ..} This View is an inner class of my activity displaying a dialog interface given the ability to paint things with finger. So, I need your help to know why I can't change the name of the button, although it is an existing button, and why the click is not detected. I tried to create a new view extending GroupView, to put my button below the Canvas, but it is not really working. I think it could be a lot better if I have my view containing only the canvas, and a button below that view, with all these components in a relative view, but all my attempts failed. Hope I'm clear with my problem. Thank you, -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en