I would give it 24 hours before bumping a question. There are people
in different time zones who may know the answer, and only haven't
responded because they're dreaming of electric sheep.


On Wed, May 20, 2009 at 3:47 PM, Junior Einsfeld
<[email protected]> wrote:
> Anyone?
>
> Regards,
> Junior
>
> On Wed, May 20, 2009 at 9:51 AM, Junior Einsfeld <[email protected]>
> wrote:
>>
>> Hello,
>>
>> I have my class below that is working. Inside it is another class that
>> extends View and that is also running.
>>
>> I need to add two buttons on this screen and then create the layout below,
>> which has a View and two buttons:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
>> android:layout_width="fill_parent"
>> android:layout_height="fill_parent"
>> android:orientation="vertical">
>>
>> <View android:id="@+id/View01"
>> android:layout_width="fill_parent"
>> android:layout_height="360px"
>> android:scrollbarSize="100px"
>> android:paddingBottom="-20px"
>> android:clickable="true"
>> android:drawingCacheQuality="auto"
>> android:focusable="true"
>> android:focusableInTouchMode="true"
>> android:keepScreenOn="true"
>> android:longClickable="true"
>> android:visibility="visible">
>> </View>
>>
>> <Button android:layout_height="wrap_content"
>>
>> android:visibility="visible"
>>
>> android:text="Cancelar"
>>
>> android:layout_marginTop="10px"
>>
>> android:layout_width="150px"
>>
>> android:width="150px"
>>
>> android:id="@+btListaServicos/cancel"/>
>>
>> <Button android:layout_height="wrap_content"
>>
>> android:text="Compor Serviços"
>>
>> android:layout_marginTop="-49px"
>>
>> android:width="150px"
>>
>> android:layout_width="150px"
>>
>> android:layout_marginLeft="170px"
>>
>> android:id="@+btListaServicos/comporServicos">
>>
>> </Button>
>>
>> </LinearLayout>
>>
>> How do I display the screen object in my View from the layout?
>>
>> In this way does not work:
>>
>> public class ServiceComposition extends Activity {
>>
>> private DViewDbAdapter dbAdapter;
>>
>> private WsServicos Servico;
>>
>> private WsMetodos Metodo;
>>
>> private Parametros Parametro;
>>
>> private Parametros Returns;
>>
>> Map<Integer, WsServicos> mServices;
>>
>> @Override
>>
>> protected void onCreate(Bundle savedInstanceState) {
>>
>> // TODO Auto-generated method stub
>>
>> super.onCreate(savedInstanceState);
>>
>> setContentView(R.layout.service_composition);
>>
>> dbAdapter = new DViewDbAdapter(this);
>>
>> dbAdapter.open();
>>
>> long idComposition = getIntent().getLongExtra("idComposition", 3);
>>
>> this.mServices = populaDados(idComposition);
>>
>> View view = findViewById(R.id.View01);
>>
>> view = new ExibeView(this, mServices);
>>
>> //setContentView(new ExibeView(this, mServices));
>>
>> }
>>
>> public class ExibeView extends View {
>>
>> private ImagemObjeto[] imagem;
>>
>> private int balID = 0; // variable to know what ball is being dragged
>>
>> private boolean moveu = false;
>>
>> private int distHorz = 60;
>>
>> private int distVert = 60;
>>
>> Map<Integer, Point> mPoint = new HashMap<Integer, Point>();
>>
>> Point point;
>>
>> /*
>>
>> * Point point0 = new Point(); Point point1 = new Point(); Point point2
>>
>> * = new Point(); Point point3 = new Point(); Point point4 = new
>>
>> * Point();
>>
>> */
>>
>> public ExibeView(Context context, Map<Integer, WsServicos> mServices) {
>>
>> super(context);
>>
>> // TODO Auto-generated constructor stub
>>
>> setFocusable(true); // necessary for getting the touch events
>>
>> int QtdServices = mServices.size();
>>
>> this.imagem = new ImagemObjeto[QtdServices];
>>
>> for (int i = 0; i < QtdServices; i++) {
>>
>> point = new Point();
>>
>> point.x = distHorz;
>>
>> point.y = distVert;
>>
>> if (distHorz >= 180) {
>>
>> distHorz = 0;
>>
>> distVert += 60;
>>
>> }
>>
>> distHorz += 60;
>>
>> mPoint.put(i, point);
>>
>> }
>>
>> for (int i = 0; i < QtdServices; i++) {
>>
>> imagem[i] = new ImagemObjeto(context, R.drawable.quadrado,
>>
>> mPoint.get(i));
>>
>> }
>>
>> }
>>
>> // the method that draws the balls
>>
>> @Override
>>
>> protected void onDraw(Canvas canvas) {
>>
>> // canvas.drawColor(0xFFCCCCCC); //if you want another background
>>
>> // color
>>
>> Paint paint = new Paint();
>>
>> paint.setColor(-16776961);
>>
>> // draw the balls on the canvas
>>
>> for (ImagemObjeto img : imagem) {
>>
>> canvas.drawBitmap(img.getBitmap(), img.getX(), img.getY(),null);
>>
>> }
>>
>> // calculaTraco(canvas, point0, point1, imagem[0]);
>>
>> }
>>
>> // events when touching the screen
>>
>> public boolean onTouchEvent(MotionEvent event) {
>>
>> int eventaction = event.getAction();
>>
>> int X = (int) event.getX();
>>
>> int Y = (int) event.getY();
>>
>> boolean move = false;
>>
>> switch (eventaction) {
>>
>> case MotionEvent.ACTION_DOWN: // touch down so check if the finger
>>
>> // is on a ball
>>
>> balID = 0;
>>
>> for (ImagemObjeto img : imagem) {
>>
>> // check if inside the bounds of the ball (circle)
>>
>> // get the center for the ball
>>
>> int centerX = img.getX() + 25;
>>
>> int centerY = img.getY() + 25;
>>
>> // calculate the radius from the touch to the center of the
>>
>> // ball
>>
>> double radCircle = Math
>>
>> .sqrt((double) (((centerX - X) * (centerX - X)) + (centerY - Y)
>>
>> * (centerY - Y)));
>>
>> // if the radius is smaller then 23 (radius of a ball is
>>
>> // 22), then it must be on the ball
>>
>> if (radCircle < 23) {
>>
>> balID = img.getID();
>>
>> moveu = false;
>>
>> break;
>>
>> }
>>
>> // check all the bounds of the ball (square)
>>
>> // if (X > ball.getX() && X < ball.getX()+50 && Y >
>>
>> // ball.getY() && Y < ball.getY()+50){
>>
>> // balID = ball.getID();
>>
>> // break;
>>
>> // }
>>
>> }
>>
>> break;
>>
>> case MotionEvent.ACTION_MOVE: // touch drag with the ball
>>
>> // move the balls the same as the finger
>>
>> if (balID > 0) {
>>
>> imagem[balID - 1].setX(X - 25);
>>
>> imagem[balID - 1].setY(Y - 25);
>>
>> moveu = true;
>>
>> }
>>
>> break;
>>
>> case MotionEvent.ACTION_UP:
>>
>> // touch drop - just do things here after dropping
>>
>> //seleciona(moveu, imagem[balID - 1]);
>>
>> if (!moveu){
>>
>> DView dv = new DView();
>>
>> dv.showAlertCustom(ServiceComposition.this);
>>
>> }
>>
>> break;
>>
>> }
>>
>> // redraw the canvas
>>
>> invalidate();
>>
>> return true;
>>
>> }
>>
>> Can help me?
>>
>> Thanks!
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to