Folks,
I am new to android development so my question is probably very basic - I am using the tabbed pane from actionbarsherlock and want to have 3 different UI for 3 tabs. However I also need one textbox in common across all tabs. To achieve the first thing my idea was to have 3 different activity classes extending the ActionBar.TabListener but instantiating those classes (using new) from the setTabListener is not working. Any solution?
Regards,
The Main Activity Class -
ActionBar.Tab aTab = getSupportActionBar().newTab();
aTab.setText("A");
aTab.setTabListener(new AActivity());
getSupportActionBar().addTab(aTab);
ActionBar.Tab bTab = getSupportActionBar().newTab();
bTab.setText("B");
bTab.setTabListener(new MessageActivity());
getSupportActionBar().addTab(bTab);
ActionBar.Tab cTab = getSupportActionBar().newTab();
cTab .setText("C");
cTab .setTabListener(new DataActivity());
getSupportActionBar().addTab(cTab );
Now the AActivity Class -
public class AActivity extends Activity implements ActionBar.TabListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.call, menu);
return true;
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
System.out.println("In A");
TextView txtView = (TextView) findViewById(R.id.aLog);
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
}
It is giving me NullPointer at
TextView txtView = (TextView) findViewById(R.id.aLog)
so am assuming the new thing is not working at all