本文整理汇总了Java中android.widget.TabHost.setOnTabChangedListener方法的典型用法代码示例。如果您正苦于以下问题:Java TabHost.setOnTabChangedListener方法的具体用法?Java TabHost.setOnTabChangedListener怎么用?Java TabHost.setOnTabChangedListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TabHost
的用法示例。
在下文中一共展示了TabHost.setOnTabChangedListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setResult(RESULT_CANCELED);
setContentView(R.layout.folder_picker);
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
tabHost.addTab(tabHost.newTabSpec("t1").setIndicator(getString(R.string.folder_new)).setContent(this));
tabHost.addTab(tabHost.newTabSpec("t2").setIndicator(getString(R.string.folder_existing)).setContent(this));
tabHost.setCurrentTab(0);
tabHost.setOnTabChangedListener(this);
onTabChanged(null);
mIconPicker = new IconPicker(this, true);
mIconSelect = (ImageView) findViewById(R.id.folder_icon);
mIconSelect.setOnClickListener(this);
}
示例2: onCreateView
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_my_files, container, false);
myFileList = (ListView) v.findViewById(R.id.myFileList);
myFileList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
myFileList.setOnItemClickListener(this);
allEntities = FileSelectHelper.getFileEntities(FileSelectorActivity.getServerResponse());
// Init tab host categories {My files}
tabHostMyFile = (TabHost) v.findViewById(R.id.tabHostMyFiles);
tabHostMyFile.setup();
initTabHost(tabHostMyFile, getMyFilesCategories(allEntities));
tabHostMyFile.setOnTabChangedListener(new MyFilesCategoriesListener());
myFileList.setAdapter(getArrayAdapterForMyFiles(allEntities, tabHostMyFile.getCurrentTabTag()));
FileEntity currentEntity = FileSelectorActivity.getCurrentEntity();
tabHostMyFile.setCurrentTab(currentTab);
FileSelectorActivity.setCurrentEntity(currentEntity);
return v;
}
开发者ID:SequencingDOTcom,项目名称:RTP-API-Gradle-Maven-Android-File-Selector-Java,代码行数:27,代码来源:MyFileActivity.java
示例3: onCreateView
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
tabHost.setup();
tabHost.setOnTabChangedListener(this);
for (int i = 0; i < pagerAdapter.getCount(); i++) {
TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
tab.setContent(android.R.id.tabcontent);
View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
TextView title = (TextView) indicator.findViewById(android.R.id.title);
title.setText(pagerAdapter.getPageTitle(i));
tab.setIndicator(indicator);
tabHost.addTab(tab);
}
viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
viewPager.setAdapter(pagerAdapter);
viewPager.setOnPageChangeListener(this);
setCurrentPosition(0);
scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
viewPager.setCurrentItem(initPageIndex);
return v;
}
示例4: createView
import android.widget.TabHost; //导入方法依赖的package包/类
private View createView(View v, LayoutInflater inflater, int currentPage) {
tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
tabHost.setup();
tabHost.setOnTabChangedListener(this);
for (int i = 0; i < pagerAdapter.getCount(); i++) {
TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
tab.setContent(android.R.id.tabcontent);
View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
TextView title = (TextView) indicator.findViewById(android.R.id.title);
title.setText(getActivity().getResources().getStringArray(R.array.result_page_title)[RMBTResultPagerAdapter.RESULT_PAGE_TAB_TITLE_MAP.get(i)]);
if (MAP_INDICATOR_DYNAMIC_VISIBILITY) {
if (i == RMBTResultPagerAdapter.RESULT_PAGE_MAP) {
indicator.setVisibility(View.GONE);
}
}
tab.setIndicator(indicator);
tabHost.addTab(tab);
}
scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
viewPager.setAdapter(pagerAdapter);
viewPager.setOnPageChangeListener(this);
setCurrentPosition(currentPage);
return v;
}
示例5: setupTabs
import android.widget.TabHost; //导入方法依赖的package包/类
protected void setupTabs()
{
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();
// get the tab tags.
mTagHidden = getResources().getString(R.string.hidden_tab);
mTagFile = getResources().getString(R.string.file_tab);
mTagAnnotate = getResources().getString(R.string.annotate_tab);
mTagPages = getResources().getString(R.string.pages_tab);
// first tab is and stays hidden.
// when the search tab is selected, we programmatically "select" this hidden tab
// which results in NO tabs appearing selected in this tab host.
setupTab(tabHost, mTagHidden, R.id.hiddenTab, R.layout.tab);
tabHost.getTabWidget().getChildTabViewAt(0).setVisibility(View.GONE);
// these tabs are shown.
setupTab(tabHost, mTagFile, R.id.fileTab, R.layout.tab_left);
setupTab(tabHost, mTagAnnotate, R.id.annotateTab, R.layout.tab);
setupTab(tabHost, mTagPages, R.id.pagesTab, R.layout.tab_right);
// start by showing the edit tab
tabHost.setCurrentTabByTag(mTagFile);
tabHost.setOnTabChangedListener(this);
}
示例6: onActivityCreated
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mTextViewTitleExample.setText(R.string.criteria_stateelement_ex1_title);
mTextViewDescriptionExample.setText(R.string.criteria_stateelement_ex1_description);
mTextViewTitleExempleAxsYes.setText(R.string.criteria_accessible_example);
mTextViewOptionEnabled.setText(getString(R.string.criteria_template_option_tb));
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout myView = (LinearLayout) inflater.inflate(R.layout.exstateelmts1_frag, null);
mFrameLayoutExampleAxsYes.addView(myView);
mTextViewTitleExempleAxsNo.setText(R.string.criteria_not_accessible_example);
LinearLayout myView2 = (LinearLayout) inflater.inflate(R.layout.exstateelmts1_frag, null);
mFrameLayoutExampleAxsNo.addView(myView2);
//HostYesAxs
String[] tabslabs = new String[2];
tabslabs[0] = getString(R.string.criteria_stateelement_ex1_public);
tabslabs[1] = getString(R.string.criteria_stateelement_ex1_private);
TabHost hostYes = initTabHost(myView);
hostYes.setOnTabChangedListener(new TabHostListener(hostYes, tabslabs));
setContentDescription(hostYes, tabslabs);
for (int i = 0; i < hostYes.getTabWidget().getChildCount(); i++)
hostYes.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_selector);
//HostNoAxs
TabHost hostNo = initTabHost(myView2);
for (int i = 0; i < hostNo.getTabWidget().getChildCount(); i++)
hostNo.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.tab_selector);
}
示例7: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cfg_strectch_editor);
mImg = (Bitmap) getIntent().getParcelableExtra("img");
mStretchRect = getExtra(KEY_STRETCH);
mPaddingRect = getExtra(KEY_PADDING);
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mTabHost.setup();
mPager = (SwipePager) findViewById(R.id.swipeTabs);
mTabHost.addTab(mTabHost.newTabSpec("t1").setIndicator(getString(R.string.npe_stretch)).setContent(this));
mTabHost.addTab(mTabHost.newTabSpec("t2").setIndicator(getString(R.string.npe_padding)).setContent(this));
mTabHost.setOnTabChangedListener(this);
mPager.setOnPageChangeListener(this);
mPager.setDisplayChild(0);
mNinePatchView = (NinePatchView) findViewById(R.id.prewiewHolder);
mNinePatchView.setBitmap(mImg);
mNinePatchView.setDim(mStretchRect);
LayoutParams lp = mNinePatchView.getLayoutParams();
lp.height = Math.max(lp.height, mImg.getHeight() * 3 / 2);
mStretchView = setRect(R.id.stretch_rect, mStretchRect, 2);
setRect(R.id.padding_rect, mPaddingRect, 3);
}
示例8: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
backGround = (LinearLayout) findViewById(R.id.background);
getSupportActionBar().hide();
tabHost = (TabHost)findViewById(R.id.tab_host);
tabHost.setup();
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
FragmentTransaction fragmentTransaction = getFragmentManager()
.beginTransaction();
if(TextUtils.equals("first",tabId)){
//
contents = new homeFragement();
}else if(TextUtils.equals("second",tabId)){
//
contents = new downloadFragment();
}
fragmentTransaction.replace(android.R.id.tabcontent, contents,"frag");
fragmentTransaction.commit();
}
});
tabHost.addTab(tabHost.newTabSpec("first").setIndicator("主页").setContent(new TabFactory(this)));
tabHost.addTab(tabHost.newTabSpec("second").setIndicator("下载").setContent(new TabFactory(this)));
// 背景图片透明度
backGround.getBackground().setAlpha(100);
}
示例9: onCreateView
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
rootView= inflater.inflate(R.layout.fragment_first_aid, container, false);
viewPager = (ViewPager) rootView.findViewById(R.id.view_pager);
List<Fragment> listFragments = new ArrayList<Fragment>();
listFragments.add(new BurnsFragment());
listFragments.add(new CprFragment());
listFragments.add(new Fragment3());
viewPager.setOffscreenPageLimit(listFragments.size());
MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(getFragmentManager(),listFragments);
viewPager.setAdapter(myFragmentPagerAdapter);
viewPager.setOnPageChangeListener(this);
tabHost = (TabHost) rootView.findViewById(R.id.tabHost);
tabHost.setup();
String[] tabNames = {"Burns", "CPR", "Fire"};
for(int i=0; i<tabNames.length; i++){
TabHost.TabSpec tabSpec;
tabSpec = tabHost.newTabSpec(tabNames[i]);
tabSpec.setIndicator(tabNames[i]);
tabSpec.setContent(new FakeContent(getActivity().getApplicationContext()));
tabHost.addTab(tabSpec);
}
tabHost.setOnTabChangedListener(this);
return rootView;
}
示例10: onCreateView
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_sample_files, container, false);
sampleFileList = (ListView) v.findViewById(R.id.sampleFileList);
sampleFileList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
sampleFileList.setOnItemClickListener(this);
allEntities = FileSelectHelper.getFileEntities(FileSelectorActivity.getServerResponse());
// Init tab host categories { Sample files}
tabHostSampleFile = (TabHost) v.findViewById(R.id.tabHostSampleFiles);
tabHostSampleFile.setup();
initTabHost(tabHostSampleFile, getSampleFilesSubCategories());
tabHostSampleFile.setOnTabChangedListener(new SampleFilesCategoriesListener());
ArrayAdapter<SpannableString> listAdapter = null;
if(tabHostSampleFile.getCurrentTabTag().equals(FileSelectHelper.ATTR_SAMPLE_ALL)) {
listAdapter = getArrayAdapterForSampleFiles(allEntities, null);
} else {
listAdapter = getArrayAdapterForSampleFiles(allEntities, tabHostSampleFile.getCurrentTabTag());
}
sampleFileList.setAdapter(listAdapter);
FileEntity currentEntity = FileSelectorActivity.getCurrentEntity();
tabHostSampleFile.setCurrentTab(currentTab);
FileSelectorActivity.setCurrentEntity(currentEntity);
return v;
}
开发者ID:SequencingDOTcom,项目名称:RTP-API-Gradle-Maven-Android-File-Selector-Java,代码行数:33,代码来源:SampleFileActivity.java
示例11: FileGalleryPreviewDialog
import android.widget.TabHost; //导入方法依赖的package包/类
public FileGalleryPreviewDialog(Context context) {
super(context);
View dialogView = getLayoutInflater().inflate(R.layout.label_dialog, null);
setView(dialogView);
setButton(DialogInterface.BUTTON_POSITIVE, getContext().getResources().getString(R.string.confirm_dialog_button),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// do nothing
}
});
tabHost = (TabHost) dialogView.findViewById(R.id.label_tabhost);
tabHost.setup();
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
// Hide/show video preview so it's not visible in background on tab change
if ("video_preview".equals(tabId)) {
videoView.setVisibility(View.VISIBLE);
videoView.start();
} else {
if (videoView != null) {
videoView.setVisibility(View.GONE);
}
}
}
});
}
示例12: LabelDialog
import android.widget.TabHost; //导入方法依赖的package包/类
@SuppressLint("InflateParams")
public LabelDialog(Context context) {
super(context);
tabs = new ArrayList<String>();
tabSpecs = new ArrayList<TabHost.TabSpec>();
setButton(DialogInterface.BUTTON_NEGATIVE, getContext().getResources().getString(R.string.cancel_dialog_button),
new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// User cancelled the dialog
}
});
View labelDialogView = getLayoutInflater().inflate(R.layout.label_dialog, null);
setView(labelDialogView);
tabHost = (TabHost) labelDialogView.findViewById(R.id.label_tabhost);
tabHost.setup();
// Hide soft keyboard on tab change
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
handleTabChange(tabId);
}
});
}
示例13: onCreateView
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_QOS_RESULTS)) {
try {
setQoSResult(new QoSServerResultCollection(new JSONArray(savedInstanceState.getString(BUNDLE_QOS_RESULTS))));
setDetailType(DetailType.valueOf(savedInstanceState.getString(BUNDLE_DETAIL_TYPE)));
} catch (JSONException e) {
//e.printStackTrace();
}
}
//DetailType detailType = DetailType.valueOf(args.getString(ARG_DETAIL_TYPE));
pagerAdapter = new QoSCategoryPagerAdapter((RMBTMainActivity) getActivity(), handler, results);
View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
tabHost.setup();
tabHost.setOnTabChangedListener(this);
for (int i = 0; i < pagerAdapter.getCount(); i++) {
TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
tab.setContent(android.R.id.tabcontent);
View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
TextView title = (TextView) indicator.findViewById(android.R.id.title);
title.setText(pagerAdapter.getPageTitle(i));
tab.setIndicator(indicator);
tabHost.addTab(tab);
}
viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
viewPager.setAdapter(pagerAdapter);
viewPager.setOnPageChangeListener(this);
setCurrentPosition(0);
scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
if (initPosition != null) {
viewPager.setCurrentItem(initPosition);
}
return v;
}
示例14: onCreate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activity=this;
requestWindowFeature(Window.FEATURE_NO_TITLE);
initialLoad();
final TabHost tabHost = getTabHost();
setupAccountsTab(tabHost);
setupBlotterTab(tabHost);
setupBudgetsTab(tabHost);
setupReportsTab(tabHost);
MyPreferences.StartupScreen screen = MyPreferences.getStartupScreen(this);
tabHost.setCurrentTabByTag(screen.tag);
tabHost.setOnTabChangedListener(this);
}
示例15: onFinishInflate
import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
mTabHost = (TabHost)findViewById(R.id.emoji_category_tabhost);
mTabHost.setup();
for (final EmojiCategory.CategoryProperties properties
: mEmojiCategory.getShownCategories()) {
addTab(mTabHost, properties.mCategoryId);
}
mTabHost.setOnTabChangedListener(this);
final TabWidget tabWidget = mTabHost.getTabWidget();
tabWidget.setStripEnabled(mCategoryIndicatorEnabled);
if (mCategoryIndicatorEnabled) {
// On TabWidget's strip, what looks like an indicator is actually a background.
// And what looks like a background are actually left and right drawables.
tabWidget.setBackgroundResource(mCategoryIndicatorDrawableResId);
tabWidget.setLeftStripDrawable(mCategoryIndicatorBackgroundResId);
tabWidget.setRightStripDrawable(mCategoryIndicatorBackgroundResId);
}
mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, this);
mEmojiPager = (ViewPager)findViewById(R.id.emoji_keyboard_pager);
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
mEmojiPager.setOnPageChangeListener(this);
mEmojiPager.setOffscreenPageLimit(0);
mEmojiPager.setPersistentDrawingCache(PERSISTENT_NO_CACHE);
mEmojiLayoutParams.setPagerProperties(mEmojiPager);
mEmojiCategoryPageIndicatorView =
(EmojiCategoryPageIndicatorView)findViewById(R.id.emoji_category_page_id_view);
mEmojiCategoryPageIndicatorView.setColors(
mCategoryPageIndicatorColor, mCategoryPageIndicatorBackground);
mEmojiLayoutParams.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);
setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);
final LinearLayout actionBar = (LinearLayout)findViewById(R.id.emoji_action_bar);
mEmojiLayoutParams.setActionBarProperties(actionBar);
// deleteKey depends only on OnTouchListener.
mDeleteKey = (ImageButton)findViewById(R.id.emoji_keyboard_delete);
mDeleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
mDeleteKey.setTag(Constants.CODE_DELETE);
mDeleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
// {@link #mAlphabetKeyLeft}, {@link #mAlphabetKeyRight, and spaceKey depend on
// {@link View.OnClickListener} as well as {@link View.OnTouchListener}.
// {@link View.OnTouchListener} is used as the trigger of key-press, while
// {@link View.OnClickListener} is used as the trigger of key-release which does not occur
// if the event is canceled by moving off the finger from the view.
// The text on alphabet keys are set at
// {@link #startEmojiPalettes(String,int,float,Typeface)}.
mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left);
mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyLeft.setOnTouchListener(this);
mAlphabetKeyLeft.setOnClickListener(this);
mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right);
mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId);
mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
mAlphabetKeyRight.setOnTouchListener(this);
mAlphabetKeyRight.setOnClickListener(this);
mSpacebar = findViewById(R.id.emoji_keyboard_space);
mSpacebar.setBackgroundResource(mSpacebarBackgroundId);
mSpacebar.setTag(Constants.CODE_SPACE);
mSpacebar.setOnTouchListener(this);
mSpacebar.setOnClickListener(this);
mEmojiLayoutParams.setKeyProperties(mSpacebar);
mSpacebarIcon = findViewById(R.id.emoji_keyboard_space_icon);
}