为元素生成具有显式 ID 的 apk
Generating apk with explicit ids for elements
在我的应用程序中,我使用了 Google 地图 API,并且我使用 hack 来重新定位缩放按钮和 MyLocation
View zoomControls = (View) getView().findViewById(0x1);
View myLocation = (View) getView().findViewById(0x2);
在我更新 android gradle 之前,工作室现在正在正常生成 apk,当我尝试生成 apk 时,它给出了以下消息
错误:错误:类型为 id [ResourceType]
的预期资源
您可以在 ids.xml 中使用
声明 ID
<resources>
<item type="id" name="zoomcontrol" />
<item type="id" name="myLocation " />
</resources>
并在 R.id 等代码中使用它们。*
View zoomControls = (View) getView().findViewById(R.id.zoomcontrol);
View myLocation = (View) getView().findViewById(R.id.myLocation );
正确获取我的位置按钮视图的方法是:
View myLocation = (View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2")
在我的应用程序中,我使用了 Google 地图 API,并且我使用 hack 来重新定位缩放按钮和 MyLocation
View zoomControls = (View) getView().findViewById(0x1);
View myLocation = (View) getView().findViewById(0x2);
在我更新 android gradle 之前,工作室现在正在正常生成 apk,当我尝试生成 apk 时,它给出了以下消息 错误:错误:类型为 id [ResourceType]
的预期资源您可以在 ids.xml 中使用
声明 ID <resources>
<item type="id" name="zoomcontrol" />
<item type="id" name="myLocation " />
</resources>
并在 R.id 等代码中使用它们。*
View zoomControls = (View) getView().findViewById(R.id.zoomcontrol);
View myLocation = (View) getView().findViewById(R.id.myLocation );
正确获取我的位置按钮视图的方法是:
View myLocation = (View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2")