简体   繁体   中英

TextViews inside ListView only shows the first word in a string with space infrequently

In a dialog I have a listview with multiple textviews. Problem is it inconsistently truncates the value after auto for some textview if I shuffle the pattern is different again. But never once all the textview displayed the entire text.

I couldn't understand why it is happening and not sure what other combination of values it might truncate. I have tried it with other values with spaces and it showed up correctly but right now it is creating problem in "auto" words only. Even tried it with UPPERCASE but still same results.

ListView layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RadioButton
        android:id="@+id/radioBtncustomerAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_margin="10dp"
        android:text="Address Type"
        android:gravity="top"
        android:checked="false"/>



    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginLeft="50dp"
        android:layout_marginBottom="10dp"
        android:layout_weight="1"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textviewcustomershipbilladdress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Address" />

        <TextView
            android:id="@+id/textviewcustomershipbillstreet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <requestFocus />
        </TextView>

        <TextView
            android:id="@+id/textviewcustomershipbillarea"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillcity"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillstate"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillcountry"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbillpincode"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <TextView
            android:id="@+id/textviewcustomershipbilldistrict"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </LinearLayout>
</LinearLayout>

Code in ListView Adapter

holder.text1.setText("auto street");
holder.text2.setText("auto add");
holder.text3.setText("auto district");
holder.text4.setText("auto pin");
holder.text5.setText("auto area");
holder.text6.setText("auto country");
holder.text7.setText("auto city");
holder.text8.setText("auto state");

DISPLAY

auto street
auto add
auto 
auto pin
auto area
auto 
auto city
auto state

Simply make your inner Linear Layout width to be match_parent , its working fine then

<LinearLayout
    android:layout_width="match_parent"<!--Set it to me match_parent-->
    android:layout_height="match_parent"
    android:layout_marginLeft="50dp"
    android:layout_marginBottom="10dp"
    android:layout_weight="1"
    android:orientation="vertical" >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM