Starting TabActivity from Activity class

127 views Asked by At

I am trying to run Activity which extends TabActivity from a class which extends Activity.

Intent intent = new Intent(this, TasksTabLayoutActivity.class);
            startActivity(intent);

This is my TabActivity class definition:

public class TasksTabLayoutActivity extends TabActivity

But this obviously wont compile.

I know TabActivity is deprecated but in this case i need to use it.

How can i start TabActivity from my activity?

1

There are 1 answers

0
vipul mittal On BEST ANSWER

Instead of this in intent constructor pass <YourActivityName>.this:

Intent intent = new Intent(MainActivity.this, TasksTabLayoutActivity.class);

Inside onclicklistener if you use this it refers to the onclicklistener class object not the context and the first argument in Intent constructor is expecting an context to be passed.

You need to supply your activity object in this argument(Activity extends context).