List of usage examples for android.widget TabHost addTab
public void addTab(TabSpec tabSpec)
From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
void postgetData() { ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha); progressbarsandaha.setVisibility(View.VISIBLE); MyRequestQueue = Volley.newRequestQueue(this); String url = "http://telyar.dmedia.ir/webservice/Get_adviser_profile/"; StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override/*from w w w . java 2s . c o m*/ public void onResponse(String response) { //This code is executed if the server responds, whether or not the response contains data. //The String 'response' contains the server's response. Log.i("ExplainMoshaver", response); //Toast.makeText(getApplicationContext(), response , Toast.LENGTH_LONG).show(); updatelistview(response); } }, new Response.ErrorListener() { //Create an error listener to handle errors appropriately. @Override public void onErrorResponse(VolleyError error) { //This code is executed if there is an error. } }) { protected Map<String, String> getParams() { Map<String, String> MyData = new HashMap<String, String>(); //Log.i("asasasasasasa",adviseridm+"/"+GlobalVar.getDeviceID()); MyData.put("adviserid", adviseridm); //Add the data you'd like to send to the server. MyData.put("deviceid", GlobalVar.getDeviceID()); //Add the data you'd like to send to the server. MyData.put("userid", GlobalVar.getUserID()); //Add the data you'd like to send to the server. Log.i("ExplainMoshaver", MyData.toString()); return MyData; } @Override protected void onFinish() { ProgressBar progressbarsandaha = (ProgressBar) findViewById(R.id.progressbarsandaha); progressbarsandaha.setVisibility(View.INVISIBLE); TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); TabHost.TabSpec tabSpec3 = tabHost.newTabSpec("nazar"); TabHost.TabSpec tabSpec2 = tabHost.newTabSpec("madarek"); TabHost.TabSpec tabSpec1 = tabHost.newTabSpec("map"); tabSpec3.setIndicator(""); Intent intent1 = new Intent(ExplainMoshaver.this, ListeComments.class); intent1.putExtra("adviseridm", adviseridm); intent1.putExtra("comments", comments); /*intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent1.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/ Log.i("aaaaaaaaaaaaaaa", comments + " "); tabSpec3.setContent(intent1); tabSpec2.setIndicator(""); Intent intent2 = new Intent(ExplainMoshaver.this, ListeLiecence.class); intent2.putExtra("adviseridm", adviseridm); intent2.putExtra("License", License); /*intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent2.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/ tabSpec2.setContent(intent2); tabSpec1.setIndicator(""); final Intent intent = new Intent(ExplainMoshaver.this, MapsActivity.class); intent.putExtra("adviseridm", adviseridm); intent.putExtra("Mainplace", Mainplace); intent.putExtra("menuya", "ya"); /*intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);*/ tabSpec1.setContent(intent); tabHost.addTab(tabSpec1); tabHost.addTab(tabSpec2); tabHost.addTab(tabSpec3); tabHost.setCurrentTab(2); } }; MyRequestQueue.add(MyStringRequest); }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
/** Build and add "moderator" tab. */ private void setupModeratorTab(Cursor sessionsCursor) { final TabHost host = getTabHost(); // Insert Moderator when available final View moderatorBlock = findViewById(R.id.moderator_block); final String moderatorLink = sessionsCursor.getString(SessionsQuery.MODERATOR_LINK); final boolean validModerator = !TextUtils.isEmpty(moderatorLink); if (validModerator) { mModeratorUri = Uri.parse(moderatorLink); // Set link, but handle clicks manually final TextView textView = (TextView) findViewById(R.id.moderator_link); textView.setText(mModeratorUri.toString()); textView.setMovementMethod(null); textView.setClickable(true);// w ww. j a v a2 s .c o m textView.setFocusable(true); // Start background fetch of moderator status startModeratorStatusFetch(moderatorLink); moderatorBlock.setVisibility(View.VISIBLE); } else { moderatorBlock.setVisibility(View.GONE); } // Insert Wave when available final View waveBlock = findViewById(R.id.wave_block); final String waveLink = sessionsCursor.getString(SessionsQuery.WAVE_LINK); final boolean validWave = !TextUtils.isEmpty(waveLink); if (validWave) { // Rewrite incoming Wave URL to punch through user-agent check mWaveUri = Uri.parse(waveLink).buildUpon().appendQueryParameter("nouacheck", "1").build(); // Set link, but handle clicks manually final TextView textView = (TextView) findViewById(R.id.wave_link); textView.setText(mWaveUri.toString()); textView.setMovementMethod(null); textView.setClickable(true); textView.setFocusable(true); waveBlock.setVisibility(View.VISIBLE); } else { waveBlock.setVisibility(View.GONE); } if (validModerator || validWave) { // Moderator content comes from existing layout host.addTab(host.newTabSpec(TAG_MODERATOR).setIndicator(buildIndicator(R.string.session_interact)) .setContent(R.id.tab_session_moderator)); } }
From source file:com.momock.outlet.tab.FragmentPagerTabOutlet.java
public void attach(final FragmentTabHolder tabHolder) { Logger.check(tabHolder != null, "Parameter tabHolder cannot be null!"); this.target = tabHolder; final TabHost tabHost = target.getTabHost(); plugs = getPlugs();/* w w w . ja v a 2 s. c om*/ Logger.check(target.getTabContent() instanceof ViewPager, "The tab content container must be a ViewPager!"); final ViewPager tabContent = (ViewPager) target.getTabContent(); tabContent.setOffscreenPageLimit(plugs.getItemCount()); tabContent.setAdapter(new FragmentPagerAdapter(target.getFragmentManager()) { @Override public Fragment getItem(final int position) { final ITabPlug plug = (ITabPlug) plugs.getItem(position); Fragment f = ((FragmentHolder) plug.getContent()).getFragment(); if (f instanceof CaseFragment) { CaseFragment cf = (CaseFragment) f; cf.setActiveCaseIndicator(new IActiveCaseIndicator() { @Override public boolean isActiveCase() { return getActivePlug() == plug; } }); } return f; } @Override public int getCount() { return plugs.getItemCount(); } void doFinishUpdate(ViewGroup container) { super.finishUpdate(container); } @Override public void finishUpdate(final ViewGroup container) { new Handler().post(new Runnable() { @Override public void run() { doFinishUpdate(container); } }); } @Override public void setPrimaryItem(ViewGroup container, int position, final Object object) { super.setPrimaryItem(container, position, object); new Handler().post(new Runnable() { @Override public void run() { if (object instanceof CaseFragment) { CaseFragment cf = (CaseFragment) object; if (cf.getCase() != null && cf.getCase().getParent() != null) cf.getCase().getParent().setActiveCase(cf.getCase()); } } }); } }); tabHost.setup(); for (int i = 0; i < plugs.getItemCount(); i++) { final ITabPlug plug = (ITabPlug) plugs.getItem(i); Logger.check(plug.getContent() instanceof FragmentHolder, "Plug in PagerTabOutlet must contains a FragmentHolder content!"); TabHost.TabSpec spec = tabHost.newTabSpec("" + i); target.setTabIndicator(spec, plug); spec.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { View v = new View(tabHost.getContext()); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }); tabHost.addTab(spec); if (getActivePlug() == plug) { tabHost.setCurrentTab(i); tabContent.setCurrentItem(i, true); } } tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { int index = tabHost.getCurrentTab(); ITabPlug plug = (ITabPlug) plugs.getItem(index); setActivePlug(plug); tabContent.setCurrentItem(index, true); } }); tabContent.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { TabWidget widget = tabHost.getTabWidget(); int oldFocusability = widget.getDescendantFocusability(); widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); tabHost.setCurrentTab(position); widget.setDescendantFocusability(oldFocusability); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.momock.outlet.tab.PagerTabOutlet.java
public void attach(TabHolder target) { Logger.check(target != null, "Parameter target cannot be null!"); Logger.check(target.getTabContent() instanceof ViewPager, "The PagerTabOutlet must contains a ViewPager content!"); this.target = target; final TabHost tabHost = target.getTabHost(); final ViewPager tabContent = (ViewPager) target.getTabContent(); plugs = getPlugs();//from w w w . j a v a 2 s .co m ViewPager pager = (ViewPager) target.getTabContent(); for (int i = 0; i < plugs.getItemCount(); i++) { ITabPlug plug = (ITabPlug) plugs.getItem(i); Logger.check(plug.getContent() instanceof ViewHolder, "The plug of PagerTabOutlet must include a ViewHolder!"); ((ViewHolder) plug.getContent()).reset(); } pager.setAdapter(new PagerAdapter() { @Override public int getCount() { return plugs.getItemCount(); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { ITabPlug plug = (ITabPlug) plugs.getItem(position); View view = ((ViewHolder) plug.getContent()).getView(); container.addView(view); return view; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } }); tabContent.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { TabWidget widget = tabHost.getTabWidget(); int oldFocusability = widget.getDescendantFocusability(); widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); tabHost.setCurrentTab(position); widget.setDescendantFocusability(oldFocusability); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }); tabHost.setup(); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { int index = tabHost.getCurrentTab(); ITabPlug plug = (ITabPlug) plugs.getItem(index); setActivePlug(plug); tabContent.setCurrentItem(index, true); } }); for (int i = 0; i < plugs.getItemCount(); i++) { final ITabPlug plug = (ITabPlug) plugs.getItem(i); Logger.check(plug.getContent() instanceof ViewHolder, "Plug in PagerTabOutlet must contains a ViewHolder content!"); TabHost.TabSpec spec = tabHost.newTabSpec("" + i); target.setTabIndicator(spec, plug); spec.setContent(new TabContentFactory() { @Override public View createTabContent(String tag) { View v = new View(tabHost.getContext()); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }); tabHost.addTab(spec); if (getActivePlug() == plug) tabHost.setCurrentTab(i); } }
From source file:com.sentaroh.android.SMBSync2.ActivityMain.java
@SuppressLint("InflateParams") private void aboutSMBSync() { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.about_dialog_title_view); final TextView title = (TextView) dialog.findViewById(R.id.about_dialog_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); title.setText(getString(R.string.msgs_dlg_title_about) + "(Ver " + packageVersionName + ")"); // get our tabHost from the xml final TabHost tab_host = (TabHost) dialog.findViewById(R.id.about_tab_host); tab_host.setup();//ww w. jav a 2 s.c o m final TabWidget tab_widget = (TabWidget) dialog.findViewById(android.R.id.tabs); if (Build.VERSION.SDK_INT >= 11) { tab_widget.setStripEnabled(false); tab_widget.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); } CustomTabContentView tabViewProf = new CustomTabContentView(this, getString(R.string.msgs_about_dlg_func_btn)); tab_host.addTab(tab_host.newTabSpec("func").setIndicator(tabViewProf).setContent(android.R.id.tabcontent)); CustomTabContentView tabViewHist = new CustomTabContentView(this, getString(R.string.msgs_about_dlg_change_btn)); tab_host.addTab( tab_host.newTabSpec("change").setIndicator(tabViewHist).setContent(android.R.id.tabcontent)); LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout ll_func = (LinearLayout) vi.inflate(R.layout.about_dialog_func, null); LinearLayout ll_change = (LinearLayout) vi.inflate(R.layout.about_dialog_change, null); final WebView func_view = (WebView) ll_func.findViewById(R.id.about_dialog_function); func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_func_desc)); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); func_view.getSettings().setBuiltInZoomControls(true); final WebView change_view = (WebView) ll_change.findViewById(R.id.about_dialog_change_history); change_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_dlg_title_about_change_desc)); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setBuiltInZoomControls(true); final CustomViewPagerAdapter mAboutViewPagerAdapter = new CustomViewPagerAdapter(this, new WebView[] { func_view, change_view }); final CustomViewPager mAboutViewPager = (CustomViewPager) dialog.findViewById(R.id.about_view_pager); // mMainViewPager.setBackgroundColor(mThemeColorList.window_color_background); mAboutViewPager.setAdapter(mAboutViewPagerAdapter); mAboutViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // util.addDebugMsg(2,"I","onPageSelected entered, pos="+position); tab_widget.setCurrentTab(position); tab_host.setCurrentTab(position); } @Override public void onPageScrollStateChanged(int state) { // util.addDebugMsg(2,"I","onPageScrollStateChanged entered, state="+state); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // util.addDebugMsg(2,"I","onPageScrolled entered, pos="+position); } }); tab_host.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { util.addDebugMsg(2, "I", "onTabchanged entered. tab=" + tabId); mAboutViewPager.setCurrentItem(tab_host.getCurrentTab()); } }); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); CommonDialog.setDlgBoxSizeLimit(dialog, true); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); dialog.show(); }