Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 2.90 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. tabHost = getTabHost();
  2.         tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
  3.        
  4.         indicatorview1 = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_styled, null);
  5.        
  6.        
  7.         first=tabHost.newTabSpec("Tab 1");
  8.         ((TextView)indicatorview1.findViewById(R.id.tabsText)).setText("");
  9.         first.setIndicator(indicatorview1);
  10.         Intent in1=new Intent(getBaseContext(),com.Orange.MakeVisits.FakeActivity.class);
  11.         first.setContent(in1);
  12.        
  13.         indicatorview2 = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_styled, null);
  14.        
  15.         second=tabHost.newTabSpec("Tab 2");
  16.         ((TextView)indicatorview2.findViewById(R.id.tabsText)).setText("Personal");
  17.         second.setIndicator(indicatorview2);
  18.         Intent in2 = new Intent(this, Personnal.class);
  19.         second.setContent(in2);
  20.        
  21.         indicatorview3 = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_styled, null);
  22.        
  23.         third=tabHost.newTabSpec("Tab 3");
  24.         ((TextView)indicatorview3.findViewById(R.id.tabsText)).setText("Settings");
  25.         third.setIndicator(indicatorview3);
  26.         Intent in3 = new Intent(this, Settings.class);
  27.         third.setContent(in3);
  28.        
  29.         indicatorview4 = android.view.LayoutInflater.from(this).inflate(R.layout.tabs_bg_styled, null);
  30.        
  31.         fourth=tabHost.newTabSpec("Tab 4");
  32.         ((TextView)indicatorview4.findViewById(R.id.tabsText)).setText("");
  33.         fourth.setIndicator(indicatorview4);
  34.         Intent in4 = new Intent(this, Settings.class);  ??
  35.         fourth.setContent(in4);                         ??
  36.      
  37.         tabHost.addTab(first);
  38.         tabHost.addTab(second);
  39.         tabHost.addTab(third);
  40.         tabHost.addTab(fourth);
  41.          
  42.        
  43.         tabHost.setOnTabChangedListener(new OnTabChangeListener(){
  44.  
  45.         public void onTabChanged(String tabId) {
  46.         if(TAB_1_TAG.equals(tabId)) {
  47.             finish();
  48.         }
  49.         if (tabId.equals("Tab 4")){
  50.             System.out.println("44444");
  51.             View v = tabHost.getCurrentView();
  52.             registerForContextMenu(v);
  53.             v.showContextMenu();
  54.         }
  55.    
  56.         }});
  57.        
  58.        
  59.         tabHost.setCurrentTab(1);
  60.  
  61.     }
  62.    
  63.     @Override
  64.         public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
  65.             super.onCreateContextMenu(menu, v, menuInfo);
  66.             MenuInflater inflater = getMenuInflater();
  67.             inflater.inflate(com.Orange.R.menu.context_menu, menu);
  68.         }
  69.     @Override
  70.     public boolean onContextItemSelected(MenuItem item) {
  71.       AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
  72.      
  73.             Toast.makeText(this, "You have chosen the context menu option ",Toast.LENGTH_SHORT).show();
  74.             return true;
  75.  
  76.       }