Your onClick() is empty so one would expect nothing to happen. What was the expected behavior?
On Feb 18, 8:59 am, furkan katman <[email protected]> wrote: > here is the code .. > > package com.android.KickOffPro; > > import java.util.Random; > > import android.app.Activity; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.view.ViewGroup.LayoutParams; > import android.widget.Button; > import android.widget.TextView; > > public class KickOffActivity extends Activity implements > OnClickListener { > private Button GenerB; > private Units e, e1, e2, e3, e4; > private static int turn; > private final LayoutParams Lpx = new LayoutParams( > LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > // GenerB=(Button)findViewById(R.id.Generate); > // GenerB.setOnClickListener(this); > // turn=0; > e = new Units(this, 100, 100); > e1 = new Units(this, 100, 150); > e2 = new Units(this, 100, 200); > e3 = new Units(this, 100, 250); > e4 = new Units(this, 100, 300); > > e.setOnClickListener(this); > e1.setOnClickListener(this); > e2.setOnClickListener(this); > e3.setOnClickListener(this); > e4.setOnClickListener(this); > this.addContentView(e, Lpx); > this.addContentView(e1, Lpx); > this.addContentView(e2, Lpx); > this.addContentView(e3, Lpx); > this.addContentView(e4, Lpx); > > } > > public void onClick(View v) { > // TODO Auto-generated method stub > > } > > } > > -----onclicklistener doesnt acccept all elements > package com.android.KickOffPro; > > import android.R.color; > import android.content.Context; > import android.graphics.Canvas; > import android.graphics.Color; > import android.graphics.Paint; > import android.graphics.Rect; > import android.view.KeyEvent; > import android.view.MotionEvent; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > > public class Units extends View > { > public int ypoint; > public int xpoint; > String txt; > private Canvas canos; > private Paint RedPen; > public Units(Context context, int Xp,int Yp) { > super(context); > > ypoint=Yp; > xpoint=Xp; > txt=""; > // TODO Auto-generated constructor stub > > } > > @Override > protected void onDraw(Canvas canvas) { > // TODO Auto-generated method stub > super.onDraw(canvas); > > Rect unitSquare=new Rect(); > unitSquare.union(xpoint, ypoint, xpoint+30, ypoint+30); > > RedPen=new Paint(); > RedPen.setColor(Color.RED); > RedPen.setStyle(Paint.Style.STROKE); > canvas.drawRect(unitSquare, RedPen); > canos=canvas; > canos.drawText(txt, xpoint, ypoint+10,RedPen); > > } > > public void TxtToDraw(String txtx) > { > txt=txtx; > invalidate(); > > } > > > > }- Hide quoted text - > > - Show quoted text - -- 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

