2
我试图用CommonsWare's Example
定制片段&标题在图形页面视图但是我不能够自定义代码片段的字样。
运气好吗?使用自定义字样在地图V2
我试图用CommonsWare's Example
定制片段&标题在图形页面视图但是我不能够自定义代码片段的字样。
运气好吗?使用自定义字样在地图V2
如果您从CommonsWare扩展该示例,则应该有一个PopupAdapter来负责显示InfoWindow。
我延展的PopupAdapter从我的资产文件夹中加载一个字体,并将其设置为标题和摘要视图的字体
class PopupAdapter implements InfoWindowAdapter {
LayoutInflater inflater = null;
// Context is most likely the map hosting activity.
// We need this so we get access to the Asset Manager
Context context = null;
PopupAdapter(LayoutInflater inflater, Context context) {
this.inflater = inflater;
this.context = context;
}
@Override
public View getInfoWindow(Marker marker) {
return (null);
}
@Override
public View getInfoContents(Marker marker) {
View popup = inflater.inflate(R.layout.popup, null);
TextView tv = (TextView) popup.findViewById(R.id.title);
tv.setText(marker.getTitle());
// We load a typeface by using the static createFromAssets method
// and provide the asset manager
// and a path to the file within the assets folder
Typeface tf = Typeface.createFromAsset(context.getAssets(),
"GoodDog.otf");
// then set the TextViews typeface
tv.setTypeface(tf);
tv = (TextView) popup.findViewById(R.id.snippet);
tv.setText(marker.getSnippet());
tv.setTypeface(tf);
return (popup);
}
}
我已经下来投给了以下原因,[Android不支持OTF ](http://stackoverflow.com/a/1430320/1008278)。在InfoWindowAdapter中不能识别'getAssets()'。我强烈建议您在回答之前确保您实施代码,否则可能会误导用户。 – VenomVendor 2013-03-31 14:33:59
getAssets()是Context类的一个方法,它是PopupAdapters构造函数的参数。 Android支持OTF,但不支持1.0版本,甚至在链接中提供的更新中。我不是100%确定的,因为OTF支持在Android中,但我的示例在运行4.2.2的Galaxy Nexus上运行。 – 2013-03-31 14:44:51
我已将您的代码替换为我的代码,正在收到运行时错误。 – VenomVendor 2013-03-31 14:56:46