TextView doesn't display all the text
In my app I can't see in my notification all the text I display. I put \n but this doesn't help me and I don't understand why.
this is proba.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:padding="3dp">
<ImageView android:id="@+id/image" android:layout_width="wrap_conte开发者_JAVA百科nt"
android:layout_height="fill_parent" android:layout_marginRight="10dp" />
<TextView android:id="@+id/notif" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:textColor="#000" />
</LinearLayout>
and here is the code :
RemoteViews contentView = new RemoteViews(getPackageName(),
R.layout.proba);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.notif,
"Today,you must go for shopping for your list '" + list + "'. "
+ "Don't forget!!!" + "\n" + "You must buy :" + "\n"
+ s.toString() + "\n");
notification.contentView = contentView;
where in s is a StringBuilder and in s I have something like this :" onions 1kg,tomatoes 2 kg,..."
A stringBuilder is not a string. Use s.toString()
to actually get a string.
By default, TextView
s are single-line (TextView documentation). You can make them multi-line by adding android:singleLine="false"
to your proba.xml
.
精彩评论