J'utilise le commaEllipsize
:commaEllipsize ne fonctionne pas
mon fichier xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="asdasdasd"/>
</LinearLayout>
fichier java:
TextView txt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (TextView) findViewById(R.id.txt);
TextPaint p = txt.getPaint();
String strTitle = "Moe, Joe, Isaac, Bethany, Cornelius, Charlie";
txt.setText(strTitle);
float avail = txt.getMeasuredWidth();
CharSequence ch = TextUtils.commaEllipsize(strTitle, p, avail, "one more", "%d more");
txt.setText(ch);
}
Quand je lance ce code, puis CharSequence ch me donne rien . c'est vide. Lorsque je débogue ce code, il affiche float avail = 0.0
.
alors comment puis-je utilisé cela?