我正在尝试使用RelativeLayout自定义InfoWindow作为我的标记,但我NullPointerException每次都会showInfoWindow调用(通过点击Marker或以编程方式).我正在使用Google Maps Android API v2.
例外:
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:465)
at android.view.View.measure(View.java:15172)
at maps.a.y.i(Unknown Source)
at maps.a.y.a(Unknown Source)
at maps.a.w.a(Unknown Source)
at maps.a.bd.a(Unknown Source)
at maps.y.bw.b(Unknown Source)
at maps.y.bw.a(Unknown Source)
at maps.a.dh.a(Unknown Source)
at maps.a.n.c(Unknown Source)
at maps.a.dw.a(Unknown Source)
at maps.a.bd.c(Unknown Source)
at maps.a.dq.onSingleTapConfirmed(Unknown Source)
at maps.e.v.onSingleTapConfirmed(Unknown Source)
at maps.e.j.handleMessage(Unknown Source)
...
Run Code Online (Sandbox Code Playgroud)
我的代码:
*custom_infowindow.xml*
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dip" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" …Run Code Online (Sandbox Code Playgroud) android google-maps nullpointerexception google-maps-android-api-2
我有一个与Android Wear集成的消息传递应用程序.与环聊类似,在Android Wear智能手表中选择通知时,您可以滑动到显示与所选消息对应的对话的第二张卡.我通过BigTextStyle通知实现它,但我需要知道chars BigTextStyle支持的最大数量,这样我就可以在对话太大而无法完全适应时正确修剪对话.我在文档上找不到这个信息.
经过一些调查,max chars大约是5000,至少在Android Wear模拟器中是这样.因此,我可以这样做:
// scroll to the bottom of the notification card
NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender().setStartScrollBottom(true);
// get conversation messages in a big single text
CharSequence text = getConversationText();
// trim text to its last 5000 chars
int start = Math.max(0, text.length() - 5000);
text = text.subSequence(start, text.length());
// set text into the big text style
NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle().bigText(text);
// build notification
Notification notification = new …Run Code Online (Sandbox Code Playgroud)