启动子选项卡活动时,Android Map(V2)标记InfoWIndowClickListener冻结(然后崩溃) [英] Android Map (V2) Marker InfoWIndowClickListener freezes (then crashes) when start child tab activity
问题描述
googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
public void onInfoWindowClick(Marker marker) {
Intent rest_list = new Intent(getParent(), RestFullDetail.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("mapRestDetail", rest_list);
}
});
当我点击信息窗口时,信息窗口会冻结,并且不会导航到其他选项卡子活动.冻结并崩溃时,它不会产生任何logcat信息.
When i tap on info window, info window freezes and doesn't navigate to another tab child activity. While freezing and crashing its not producing any logcat information.
好的解决方案:
我自己找到了解决方案.尝试在infowindowclick和上执行异步任务执行将所有代码(将在信息窗口中单击运行)放入后执行.就像魅力一样.
I found solution myself. Try async task excute on infowindowclick and put all the code (which was to run under info window click) in postexecute. It works like charm.
推荐答案
您需要按照以下步骤执行自定义信息窗口单击:
You need to follow these steps to perform custom info window click :
->实现"GoogleMap.OnInfoWindowClickListener" 和"GoogleMap.InfoWindowAdapter"
--> 扩展自定义信息窗口:
--> Inflate custom info window :
@Override
public View getInfoContents(Marker marker) {
// Inflate the layouts for the info window, title and snippet.
View infoWindow = getActivity().getLayoutInflater().inflate(R.layout.custom_info_contents, null);
TextView txtStoreName = ((TextView) infoWindow.findViewById(R.id.txtStoreName));
txtStoreName.setText(marker.getTitle());
TextView txtStoreAddress = ((TextView) infoWindow.findViewById(R.id.txtStoreAddress));
txtStoreAddress.setText(marker.getSnippet());
return infoWindow;
}
->设置侦听器://InfoWindowClick
--> Set Listener : // InfoWindowClick
mGoogleMap.setOnInfoWindowClickListener(this);
@Override
public void onInfoWindowClick(final Marker marker) {
// TODO Here perform action on balloon view click
mRecyclerStore.post(new Runnable() {
@Override
public void run() {
StoreModel model = (StoreModel) marker.getTag();
boolean isAddedToBackStack = true;
StoreDetailsAndProductListFragment storeDetailsAndProductListFragment = new StoreDetailsAndProductListFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(ExtrasUtil.STORE, model);
storeDetailsAndProductListFragment.setArguments(bundle);
showOtherFragment(storeDetailsAndProductListFragment, getActivity().getFragmentManager(), isAddedToBackStack);
}
});
}
这篇关于启动子选项卡活动时,Android Map(V2)标记InfoWIndowClickListener冻结(然后崩溃)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!