How to change text of textview of different Activity

Atmospheric Productions :

So what I have in my project is some markers and custominfowindow. I have specific functions according to makers with on click custominfolistner:

 @Override
    public void onInfoWindowClick(Marker marker) {

        if("India".equals(marker.getTitle())) {
            Intent intent = new Intent(this,country.class);
            startActivity(intent);

        }
        if("Australia".equals(marker.getTitle())){
          Intent intent = new Intent(this,country.class);
          startActivity(intent);
        }

    }

I made markers with this code:

LatLng India = new LatLng(23.52, 78.59);
                     mMap.addMarker(new MarkerOptions()
                             .position(India)
                             .title("India"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(India));

        mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter(MapsActivity.this));

Now when someone clicks on the custom infoindow of india it opens an activity called country. Now currently there are 2 textviews on this activity: textview1 textview2. Now what I want is when someone clicks on Sydney and opens India activity the 2 textviews show Sydney is clicked and the other shows some information on sydney and when someone clicks on India the textview1 show India and the other shows textviews shows information on India. How can i do this. I am very new to this so please answer in detail also i tried to do it like this in country activity but it din't work: Activity of country

if("India".equals(marker.getTitle())) {
           tetxview1.settext("India");

        }
Pratik Butani :

You can pass title in Intent whichever clicked.

Intent intent = new Intent(this,country.class);
intent.putExtra("title",marker.getTitle());
startActivity(intent);

and In Next Activity, You can get it by Bundle.

Bundle bundle = getIntent().getExtras();
if(bundle != null) {
     String title = bundle.getString("title");

     //Set it to your textview...
}

Hope you will understand, Thank you.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=31769&siteId=1