On an Android phone from AT&T, you can hear a click sound when navigating through tabs. How do I get the Tab widget to play a sound on the click of a tab?
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
//PLAY SOUND HERE
MediaPlayer tabClick = MediaPlayer.create(TabBarActivity.this, R.Raw.gling_click);
tabClick.start();
}
)};
step 1 from the tutorial is this:
See where it says NEW CODE HERE **? You want to add an OnTabChangedListener to the tabHost. This is an object that is “listening” for the user to change tabs. When a tab changes, the
onTabChanged(String tabID)method is run.Add the
onTabChangedListenerafter tutorial step 1; It’s within theonCreate()method.Then, get on google and look up
android play a soundand get that code into where it says //PLAY SOUND HERE.