Я новичок в разработке Android. Моя цель - сделать видео, работающее внутри настраиваемого информационного окна в Google Maps V2 API android. Я знаю, как сделать видеоролик внутри представления (загружая серию изображений, делая их похожими на фильм). Также я узнал, как загружать изображение в настраиваемом инфо-окне. Я пытаюсь сделать слайд-шоу изображений внутри infowindow. Но проблема в том, что загружается только первое изображение. Если не указано иное, я снова нажимаю на маркер, содержимое infoWindow не обновляется. Я прикрепляю код ниже
main_activity.java
public class BasicMapActivity extends FragmentActivity {
private GoogleMap mMap;
static final LatLng MELBOURNE = new LatLng(-37.81319, 37.00);
public static LatLng argOut = null;
public static String msg = "1";
private static ImageView imageView;
int i=0;
int imgid[]={R.drawable.a,R.drawable.b,R.drawable.c,R.drawable.d};
RefreshHandler refreshHandler=new RefreshHandler();
class RefreshHandler extends Handler{
@Override
public void handleMessage(Message msg) {
BasicMapActivity.this.updateUI(null);
}
public void sleep(long delayMillis){
this.removeMessages(0);
sendMessageDelayed(obtainMessage(0), delayMillis);
}
};
public void updateUI(Marker markerShowingInfoWindow){
refreshHandler.sleep(2000);
if(i<imgid.length){
imageView.setImageResource(imgid[i]);
if (markerShowingInfoWindow != null && true) {
markerShowingInfoWindow.showInfoWindow();
}
i++;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.basic_demo);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
if (mMap == null) {
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.title("Melbourne")
.snippet("Population: 4,137,400"));
// when a infowindow is tapped (infowindow open request)
mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker arg0) {
String test = arg0.getTitle();
View v = getLayoutInflater().inflate(R.layout.windowlayout, null);
imageView = (ImageView) v.findViewById(R.id.imageView1);
imageView.setVisibility(View.VISIBLE);
if(!test.equalsIgnoreCase("Melbourne")){
updateUI(arg0);
} else {
imageView.setImageDrawable(getResources().getDrawable(R.drawable.badge_wa));
}
return v;
}
});
}
}
ErrorStackTrace выглядит следующим образом:
11-03 13:58:19.000: E/AndroidRuntime(5095): FATAL EXCEPTION: main
11-03 13:58:19.000: E/AndroidRuntime(5095): java.lang.StackOverflowError
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.util.ArrayList.<init>(ArrayList.java:81)
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.lang.Throwable.<init>(Throwable.java:66)
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.lang.Throwable.<init>(Throwable.java:108)
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.lang.Exception.<init>(Exception.java:60)
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:50)
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.lang.reflect.Constructor.constructNative(Native Method)
11-03 13:58:19.000: E/AndroidRuntime(5095): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity$1.getInfoContents(BasicMapActivity.java:123)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.GoogleMap$10.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.internal.d$a.onTransact(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bnw.b(SourceFile:112)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.a(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.b(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bn.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bqt.onTransact(SourceFile:145)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.internal.d$a$a.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.Marker.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity.updateUI(BasicMapActivity.java:74)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity$1.getInfoContents(BasicMapActivity.java:127)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.GoogleMap$10.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.internal.d$a.onTransact(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bnw.b(SourceFile:112)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.a(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.b(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bn.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bqt.onTransact(SourceFile:145)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.internal.d$a$a.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.Marker.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity.updateUI(BasicMapActivity.java:74)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity$1.getInfoContents(BasicMapActivity.java:127)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.GoogleMap$10.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.internal.d$a.onTransact(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bnw.b(SourceFile:112)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.a(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.b(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bn.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bqt.onTransact(SourceFile:145)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.internal.d$a$a.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.Marker.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity.updateUI(BasicMapActivity.java:74)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity$1.getInfoContents(BasicMapActivity.java:127)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.GoogleMap$10.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.internal.d$a.onTransact(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bnw.b(SourceFile:112)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.a(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bm.b(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at maps.ag.bn.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at bqt.onTransact(SourceFile:145)
11-03 13:58:19.000: E/AndroidRuntime(5095): at android.os.Binder.transact(Binder.java:297)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.internal.d$a$a.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.model.Marker.showInfoWindow(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity.updateUI(BasicMapActivity.java:74)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.example.mapdemo.BasicMapActivity$1.getInfoContents(BasicMapActivity.java:127)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.GoogleMap$10.g(Unknown Source)
11-03 13:58:19.000: E/AndroidRuntime(5095): at com.google.android.gms.maps.internal.d$a.onTransact(Unknown Source)
Я пытаюсь вызвать showInfoWindow() для объекта-маркера, который передается функции updateUI в getInfoContents. Что я делаю неправильно и как правильно вызывать окно showInfo после того, как imageView внутри infoWindow получает новое изображение?