1

Kindly help.I am new to android TABS. I want my button to take me to a new page when it is clicked on. Currently I am trying to implement the same method as I used to.

public class PhotosActivity extends Activity {
    private Button btnRegularRecrutor;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photos_layout);
        btnRegularRecrutor = (Button) findViewById(R.id.RegularRecruters);

        btnRegularRecrutor.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                // TODO Auto-generated method stub
                Intent A = new Intent(MainActivity.this, RegularRecruters.class);

                startActivity(A);

            }
        });
    }
}

The button should take me to RegularRecruters.class. Thanks in advance

Vicky Tilwani
  • 21
  • 1
  • 4

1 Answers1

0

Change:

Intent A = new Intent(MainActivity.this, RegularRecruters.class);

into:

Intent A = new Intent(PhotosActivity.this, RegularRecruters.class);

if you want to switch between tabs:

TabActivity main = (TabActivity) getParent(); // get the main 'TabActivity' from a Child (tab)
TabHost tabHost = main.getTabHost(); // get a handle to the TabHost
tabHost.setCurrentTab(<index>)
Strider
  • 4,452
  • 3
  • 24
  • 35
  • Thanks for reply. But it isint working yet. I guess it has something to do with TABHOST as I am using TABS. – Vicky Tilwani Apr 17 '15 at 20:33
  • you want to switch between tabs? then check my edit. if not than please be more specific ;) – Strider Apr 17 '15 at 20:45
  • Everything is working perfect in the tabs(switching). When we click on tabs the text is also being displayed properly. I am just not able to use buttons inside those tab pages. :) Tab1 --Button Tab2 --Text Tab3 --Text The button in Tab1 not responding after the code i have used :) – Vicky Tilwani Apr 17 '15 at 20:57
  • maybe [this](http://stackoverflow.com/questions/9387647/buttons-inside-different-tabs) is what you need – Strider Apr 17 '15 at 21:08
  • Thanks A LOTT Strider!. Exatly what I needed! Sry if I was not clear earlier. :) – Vicky Tilwani Apr 17 '15 at 21:15