Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7420101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:10:52+00:00 2026-05-29T08:10:52+00:00

Previously I’ve been looking at existing code to display a map in a tab,

  • 0

Previously I’ve been looking at existing code to display a map in a tab, and this time I’ve tried to write it myself to see if I understood it.

It runs fine without errors (screenshot), but I don’t completely understand why, and whether I’m doing this in the best way.

The part that I don’t quite understand is in the manifest.
I would have thought that android:label should be maptabview_name, but that gives me an error saying no matching resource was found.

Why does it run when using app_name for that activity?
Why can’t it find the maptabview_name resource?

Also, in MapTab2, is this the best way to start an intent?
What exactly is this telling the system? “I intend to start an activity from this class”?

Here’s my code
(It’s based on this):

MapTab2.java

package com.test.maptab2;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class MapTab2 extends TabActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Intent i = new Intent(this,MapTabView.class);

        TabHost.TabSpec spec;

        spec = getTabHost().newTabSpec("tab1");
        spec.setContent(i);
        spec.setIndicator("Map");
        getTabHost().addTab(spec);

        spec = getTabHost().newTabSpec("tab2");
        spec.setContent(R.id.detailstub);
        spec.setIndicator("Detail");
        getTabHost().addTab(spec);

        getTabHost().setCurrentTab(0);

    }

}

MapTabView.java

package com.test.maptab2;

import android.os.Bundle;
import com.google.android.maps.MapActivity;

public class MapTabView extends MapActivity {

    @Override
    public void onCreate (Bundle icicle){
        super.onCreate(icicle);
        setContentView(R.layout.maptabview);
    }

    @Override
    public boolean isRouteDisplayed(){
        return false;
    }

}

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <!-- Tab-switch panel -->
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

        <!-- Tab contents -->
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <!-- Map here -->
            <RelativeLayout android:id="@+id/mapstub"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"/>

            <!-- Other stuff -->
            <TextView android:id="@+id/detailstub"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="detail"/>

        </FrameLayout>  
    </LinearLayout>
</TabHost>

maptabview.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/maptablayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="0HRMcD5o6WrBVhmwbWpeyeavZ67PXWOvJeeCx2g"/>

</RelativeLayout>

MapTab2.Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.maptab2"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <uses-library android:name="com.google.android.maps" />

        <!--  Main  -->
        <activity android:name=".MapTab2"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!--  Map  -->
        <activity android:name=".MapTabView"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.EMBED" />
            </intent-filter>
        </activity>

    </application>
</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:10:53+00:00Added an answer on May 29, 2026 at 8:10 am

    Q1: maptabview_name has to be in a string resource file, usually at res/values/string.xml, in case you have it there and still it’s not in the resources generated file (gen/package/R.java), try removing it and let eclipse generate it again.

    Q2: AFAIK, TabHost.TabSpec.setContent(Intent intent) it’s like starting the Activity within the specified tab. I think that’s the way do do it when you deal with tabs. Since Intents are used to do a lot of things, this is a basic usage, in this case just to specify the class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Previously I used to write my object interfaces like this: // VERSION 1.0 @interface
Previously I had been using this.CommandBindings.Add( new CommandBinding(ApplicationCommands.Copy, this.cmdCopy_Executed, this.cmdCopy_CanExecute)) where cmdCopy_Executed is a
Previously I asked this question and got back this BeautifulSoup example code, which after
Previously when executing unit tests with xunit.net / testdriven.net I could see output written
I have a jquery bug and I've been looking for hours now, I can't
Previously I've been using some older version of django-registration which seems to be deprecated
Previously I asked this question: Read quicktime movie from servlet in a webpage? Basically
Previously answered questions here said that this was the fastest way: //nl is a
Previously i was able to download YouTube videos as mp3 via youtube-mp3.org Using this
Previously I had: MyClass::MyClass() : myMember(VALUE,this,5,etc.) { ... } but I need to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.