you have the right idea, first make you activity implement onClickListener, then pass onClickListener this instead. Then you need to either be extending from TextView instead of view, or be calling canvas.drawText()
On Feb 19, 4:01 pm, BobG <[email protected]> wrote: > //This actually works. Hope it helps someone. > package com.AITI.hellobutton; > > import android.app.Activity; > import android.content.Context; > import android.graphics.Canvas; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > > public class hellobutton extends Activity { > public Button button01; > public int count; > public HelloButtonView hellobuttonview; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > hellobuttonview = new HelloButtonView(this); > setContentView(R.layout.main); > > button01=(Button)findViewById(R.id.Button01); > button01.setOnClickListener(new OnClickListener(){ > @Override > public void onClick(View button01) { > hellobuttonview.dodraw(); > }//onclick > });//onclicklistener > }//oncreate > > public class HelloButtonView extends View{ > public HelloButtonView(Context context){ > super(context); > } > > @Override > protected void onDraw(Canvas canvas){ > super.onDraw(canvas); > dodraw(); > };//ondraw > > public void dodraw(){ > count++; > button01.setText("button01 count "+count); > invalidate(); > }//dodraw > }} //activity > > //-------------------------eof------------------------------------ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

