Listview and Mapview within a Tabhost

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Listview and Mapview within a Tabhost

Postby wdsl » Fri Dec 18, 2009 4:21 pm

Hi,
I have 2 Tabs.

1. A Map
2. A List of Points (from db)

My Problem is to use both in one activity. Java don't support multiple inheritance and so i see no way to use both. Maybe it is a stupid question, but i started just a view days ago and now i stick the first time.

P.S.
Nice registration questions ;-)

x=4; System.out.println(Math.sqrt(x));
wdsl
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Dec 18, 2009 4:06 pm

Top

Postby Droid123 » Sun Dec 20, 2009 8:51 am

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class myTabs extends TabActivity {
  2.  
  3.  
  4.  
  5.     @Override
  6.  
  7.     protected void onCreate(Bundle savedInstanceState) {
  8.  
  9.         super.onCreate(savedInstanceState);
  10.  
  11.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  12.  
  13.         TabHost tabHost = getTabHost();
  14.  
  15.                
  16.  
  17.         LayoutInflater.from(this).inflate(R.layout.mytabs, tabHost.getTabContentView(), true);
  18.  
  19.  
  20.  
  21.         tabHost.addTab(tabHost.newTabSpec("tab_map")
  22.  
  23.                 .setIndicator(" ", getResources().getDrawable(R.drawable.icon))
  24.  
  25.                 .setContent(new Intent(this, myList.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
  26.  
  27.                
  28.  
  29.         tabHost.addTab(tabHost.newTabSpec("tab_list")
  30.  
  31.                 .setIndicator(" ", getResources().getDrawable(R.drawable.icon))
  32.  
  33.                 .setContent(new Intent(this, myList.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
  34.  
  35.        
  36.  
  37.    }
  38.  
  39.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


So basically what this does is.. This one activity holds a tabhost with 2 tabs, myMap and myList. Whenever a tab is selected it fires an intent. You can have this intent call you map or list activity and it'll inflate within the tabhost.

Any other questions, let me know

cheers
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests