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 6879755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:53:11+00:00 2026-05-27T04:53:11+00:00

When I select a city from my 3rd tab, I want to it to

  • 0

When I select a city from my 3rd tab, I want to it to show up in the “Map” tab. For example, when I first select “Austin” as the city, it shows up on the map (as shown in the picture bellow). But when I go back to the “City” tab again and choose a different city, it doesn’t get updated in the “Map” tab. Can you please tell me if there is a way I can refresh the “MapsActicity” each time I click on the “Map” tab.

public class HelloTabWidget extends TabActivity implements OnTabChangeListener {`

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

        Resources res = getResources(); 
        TabHost tabHost = getTabHost(); 
        TabHost.TabSpec spec;  
        Intent intent;  
        mtabHost = getTabHost();
        mtabHost.setOnTabChangedListener(this);

        intent = new Intent().setClass(this, BarActivity.class);        
        spec = tabHost.newTabSpec("Name").setIndicator("Name",res.getDrawable(R.drawable.ic_tab_bar)).setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, MapsActivity.class);
        spec = tabHost.newTabSpec("Map").setIndicator("Map",res.getDrawable(R.drawable.ic_tab_map)).setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, CityActivity.class);
        spec = tabHost.newTabSpec("city").setIndicator("City", res.getDrawable(R.drawable.ic_tab_city)).setContent(intent); 
        tabHost.addTab(spec);

        tabHost.setCurrentTab(2);
    }

    public void onTabChanged(String tabId) {        
        int a = mtabHost.getCurrentTab();
        String b = Integer.toString(a); 
        if(b.equals("1"))
        {           
            Toast.makeText(getApplicationContext(), "Map Selected", Toast.LENGTH_LONG).show();
        }               
    } 
}

enter image description here

Update:

     `public class MapsActivity extends MapActivity 
     {  
MapView mapView;  
MapController mc;
GeoPoint p;`

class MapOverlay extends com.google.android.maps.Overlay
{
    @Override
    public boolean draw(Canvas canvas, MapView mapView, 
    boolean shadow, long when) 
    {
        super.draw(canvas, mapView, shadow); 
        Point screenPts = new Point();
        mapView.getProjection().toPixels(p, screenPts);
         Bitmap bmp = BitmapFactory.decodeResource(
            getResources(), R.drawable.pushpin);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
        return true;
    }
 }

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

    mapView = (MapView) findViewById(R.id.mapView);
    LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);  
    View zoomView = mapView.getZoomControls(); 

    zoomLayout.addView(zoomView, 
        new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, 
            LayoutParams.WRAP_CONTENT)); 
    mapView.displayZoomControls(true);


    String []coordinates = new String[4];
    coordinates[0] = "33.477863"; coordinates[1] = "-101.855166"; //Just in-case user didn't choose a city 

    if(CityActivity.value.equals("Austin")) { //This 'value' is recived from CityActivity. Depending on what city user chooses.
        coordinates[0] = "30.260053"; coordinates[1] = "-97.738593"; }
    else if(CityActivity.value.equals("Dallas")) {
        coordinates[0] = "33.554519"; coordinates[1] = "-101.855621"; }
    else if(CityActivity.value.equals("Slaton")) {
        coordinates[0] = "33.577863"; coordinates[1] = "-101.855166"; }


    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);

    p = new GeoPoint(
        (int) (lat * 1E6), 
        (int) (lng * 1E6));

    mc = mapView.getController();
    mc.animateTo(p);
    mc.setZoom(16); 
    mapView.invalidate();

    MapOverlay mapOverlay = new MapOverlay();
    List<Overlay> listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);     
    mapView.invalidate();
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}  }
  • 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-27T04:53:12+00:00Added an answer on May 27, 2026 at 4:53 am
    String []coordinates = new String[4];
    coordinates[0] = "33.477863"; coordinates[1] = "-101.855166"; //Just in-case user didn't choose a city 
    
    if(CityActivity.value.equals("Austin")) { //This 'value' is recived from CityActivity. Depending on what city user chooses.
        coordinates[0] = "30.260053"; coordinates[1] = "-97.738593"; }
    else if(CityActivity.value.equals("Dallas")) {
        coordinates[0] = "33.554519"; coordinates[1] = "-101.855621"; }
    else if(CityActivity.value.equals("Slaton")) {
        coordinates[0] = "33.577863"; coordinates[1] = "-101.855166"; }
    
    
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);
    
    p = new GeoPoint(
        (int) (lat * 1E6), 
        (int) (lng * 1E6));
    
    
    mc = mapView.getController();
    mc.animateTo(p);
    mc.setZoom(16); 
    mapView.invalidate();
    
    MapOverlay mapOverlay = new MapOverlay();
    List<Overlay> listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);     
    mapView.invalidate();
    

    Try to move this peace of code in OnResume() Method

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

Sidebar

Related Questions

I want to create a MySQL Query similar to SELECT city, state, country FROM
I would like to use something like the following: SELECT city FROM cities WHERE
Can this be done w/ linqtosql? SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime FROM Incidents GROUP
I have the following query that works well. SELECT DISTINCT city,region1,region2 from static_geo_world where
var cityList = from country in doc.Element(result) .Element(cities) .Descendants(city) select new { Name =
SELECT airline, airports.icao_code, continent, country, province, city, website FROM airlines FULL OUTER JOIN airports
Suppose I am calling a query SELECT name, city, country FROM People. Once I
INSERT INTO geo (city, country, latitude, longitude) SELECT ansiname, country_code, latitude, longitude FROM geonames2
When I select all data from table/view person from database city I'll do it
In SQL Server, I have this query SELECT DISTINCT City FROM Person.Address But this

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.