Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start one activity from Customized View

How to start one activity from another View (another activity View)

For example,

public class CorrectSmoothGloflo extends Activity {
  .......................
  setContentView(new Panel(this));
}


public class Panel extends View {

   //This view class contains some drawable operation
   // Here i want to start another Activity like this

   Intent i=new Intent(CorrectSmoothGloflo.this,Screen.class);
    startActivity(i);   
}

I cant do this operation. Because this is the View, that will not work, because View does not have startActivity(). How to implement this? please give some guidelines.

like image 805
ios developer Avatar asked Mar 05 '11 09:03

ios developer


People also ask

How do I start my activity results?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken text view to show on Activity result data.


1 Answers

Obtain a Context object and use its startActivity() method:

Context context = getContext();
Intent i = new Intent(context, Screen.class);
context.startActivity(i);
like image 198
Konstantin Burov Avatar answered Oct 12 '22 23:10

Konstantin Burov