Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't change text of a TextView in android
    primarykey
    data
    text
    <p>I have a view, inflated from custom layout, which contains a <code>TextView</code>. I tried to set <code>TextView</code> text both from xml via string resource and programmatically after layout inflating - I'm still getting only <code>android.widget.RelativeLayout@4166f2d8</code> instead of normal text. What am I doing wrong?</p> <p>Xml:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layers_list_item_root" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp" &gt; &lt;CheckBox android:id="@+id/layers_list_item_switch" blablabla... /&gt; &lt;TextView android:id="@+id/layers_list_item_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="left|center_vertical" android:layout_toLeftOf="@id/layers_list_item_switch" android:selectAllOnFocus="true" android:text="@string/layers_list_default_text" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:scrollHorizontally="true" android:textColor="@android:color/black" android:textSize="16sp" android:textStyle="bold" android:typeface="serif" android:clickable="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>View inflating method:</p> <pre><code>public View createLayerListItem (String text) { View v = View.inflate(this, R.layout.layers_list_item, null); TextView text_view = (TextView) v.findViewById(R.id.layers_list_item_text); text_view.setText(text); return v; } </code></pre> <p>And this views are used to fill some <code>ListView</code>:</p> <pre><code>ListView layers_list = (ListView)layers_dialog.findViewById(R.id.layers_list); ArrayAdapter&lt;View&gt; adapter = new ArrayAdapter&lt;View&gt;(this, R.layout.layers_list_item, R.id.layers_list_item_text); adapter.add(createLayerListItem("Test 1")); adapter.add(createLayerListItem("")); adapter.add(createLayerListItem("Very very very very very very long line")); </code></pre> <p>All my <code>TextViews</code> are wrong, showing <code>android.widget.RelativeLayout@4166f2d8</code>. I also tried to use default text from xml, not changing it from code at all - still I didn't got my text from resource, only address.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload