Hi Divya

For Your requirement it is better to use the tab host in android ......  u
just research abt tab host in android ....

But i correct the program as per ur requirement ....but some problems are
there ,. the view is overwriting the existing view and one thing is that ,
you need to make the code for remove and redraw the canvas......


DrawTest.java
=============

package com.DrawTest;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

public class DrawTest extends Activity implements OnClickListener
{

               //private DrawActivity draw;
               DrawView drawview;
               CircleView circleView;
               Button square,circle;
               FrameLayout Frame;

   /** Called when the activity is first created. */

       @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);


        Frame=(FrameLayout)findViewById(R.id.MyFreame);
       drawview=new DrawView(this);
       circleView=new CircleView(this);


       square=(Button)findViewById(R.id.buttonTest);
       square.setOnClickListener(this);
       circle=(Button)findViewById(R.id.circleButton);
       circle.setOnClickListener(this);
       }

       public void onClick(View v)
       {
           switch (v.getId()) {
           case R.id.circleButton:

               Frame.addView(circleView);
              // circleView.setBackgroundColor(Color.rgb(40,100,20));
              // circleView.findViewById(R.id.CircleViewId);
              // setContentView(circleView);

               break;

           case R.id.buttonTest:

               //drawview.setBackgroundColor(Color.WHITE);
              // drawview.findViewById(R.id.DrawViewId);
              /// setContentView(drawview);
               Frame.addView(drawview);
               break;
           }
       }
}


*DrawView and CircleView has no change.....*.........
========================================


main.xml
===========

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout
       xmlns:android="http://schemas.android.com/apk/res/android";
       android:visibility="visible"
       android:id="@+id/MyFreame"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">


       <com.DrawTest.DrawView
   android:id="@+id/DrawViewId"
   android:layout_width="200dp"
   android:layout_height="200dp">
   </com.DrawTest.DrawView>

   <com.DrawTest.CircleView
   android:id="@+id/CircleViewId"
   android:layout_width="200dp"
   android:layout_height="200dp">
   </com.DrawTest.CircleView>

<LinearLayout

       android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="horizontal"
   android:gravity="bottom">


        <Button
           android:layout_height="wrap_content"
           android:text="Circle"
           android:id="@+id/circleButton"
           android:layout_width="160dp"
           >
   </Button>

   <Button
           android:layout_height="wrap_content"
           android:text="Square"
           android:id="@+id/buttonTest"
           android:layout_width="160dp">
   </Button>




</LinearLayout>
</FrameLayout>
==============================


go through the code and modify as u need........

or try TABHOST

Thanks

RATHEESH

-- 
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

Reply via email to