simple webview activity which takes an image url as an argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onClick(View v) { | |
Intent i; | |
switch (v.getId()) { | |
.... | |
case R.id.east_map_button: | |
i = new Intent(this, MapZoom.class); | |
i.putExtra(MAP_URL, "file:///android_res/drawable/east.png"); | |
startActivity(i); | |
break; | |
case R.id.west_map_button: | |
i = new Intent(this, MapZoom.class); | |
i.putExtra(MAP_URL, "file:///android_res/drawable/west.png"); | |
startActivity(i); | |
break; | |
case R.id.expo_map_button: | |
i = new Intent(this, MapZoom.class); | |
i.putExtra(MAP_URL, "file:///android_res/drawable/expo_floor.png"); | |
startActivity(i); | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.usefuldevelopment.usitt2011; | |
import static com.usefuldevelopment.usitt2011.Constants.MAP_URL; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.webkit.WebView; | |
public class MapZoom extends Activity { | |
private String map; | |
private WebView browser; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.map_zoom); | |
browser = (WebView) findViewById(R.id.web_view); | |
map = (savedInstanceState == null) ? null : | |
(String) savedInstanceState.getSerializable(MAP_URL); | |
if (map == null) { | |
Bundle extras = getIntent().getExtras(); | |
map = extras != null ? extras.getString(MAP_URL) | |
: null; | |
} | |
loadMap(); | |
} | |
private void loadMap() { | |
Log.d("LoadMap", map); | |
if (map != null) { | |
browser.loadUrl(map); | |
} | |
} | |
@Override | |
protected void onSaveInstanceState(Bundle outState) { | |
super.onSaveInstanceState(outState); | |
outState.putSerializable(MAP_URL, map); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
loadMap(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment