Note that there are some explanatory texts on larger screens.

plurals
  1. POsetText() is not working on inflated Text view
    primarykey
    data
    text
    <p><br> Following is the code here I was testing that when I inflate any particular widget then I cannot really do setText on it. it overwrites the text and returns the last string. Here in the output screen I can see five textview added from xml but the one programmatically I am trying to set is not happening I see only one text from str[] i.e str[5] which is the last one in the array. Please let me know if i am able to explain my problem.</p> <pre><code>public class TestInflate extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View[] inflated = new View[5]; for(int i = 0; i&lt;5; i++) { TableLayout myTableLayout = (TableLayout)findViewById(R.id.TableLayout); LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflated[i] = inflater.inflate(R.layout.testbutton, myTableLayout); TextView userName = (TextView)inflated[i].findViewById(R.id.myName); userName.setText(str[i]);//here i should get name but not getting } } String[] str = {"a","s","d","r","t"}; } </code></pre> <p>and my testButton.xml is as follows</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TableRow xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/TableRow" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"&gt; &lt;TextView android:id="@+id/Name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10px" android:text="Name :" android:textStyle="bold" android:layout_weight=".25" &gt;&lt;/TextView&gt; &lt;TextView android:id="@+id/myName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="italic" android:layout_weight=".5" &gt;&lt;/TextView&gt; &lt;/TableRow&gt; </code></pre> <p>and main.xml is </p> <pre><code> &lt;ScrollView android:id="@+id/Scroll" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;TableLayout android:id="@+id/TableLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:clickable="true"&gt; &lt;/TableLayout&gt; &lt;/ScrollView&gt; </code></pre> <p>Edit- and teh optput is like this </p> <pre><code>My output is like this Name : t //str[5] Name : Name : Name : Name : </code></pre>
    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.
 

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