Note that there are some explanatory texts on larger screens.

plurals
  1. POTextview.setText does not work
    primarykey
    data
    text
    <p>I got the following problem:</p> <p>i have a method that requests an update from a websocket server:</p> <pre><code>public Playlist(Activity a) { this.activity = a; activity.setContentView(R.layout.player); KMC.c.send("MyPlayer::CurrentSongList('ID,ArtistName,Title,AlbumName')"); } </code></pre> <p>The result is succesfully received by the following function:</p> <pre><code>public void UpdateCPL(JSONArray jArray) { TextView TVti = (TextView) this.activity.findViewById(R.id.title); TextView TVar = (TextView) this.activity.findViewById(R.id.artist); TextView TVal = (TextView) this.activity.findViewById(R.id.album); ImageView IV = (ImageView) this.activity.findViewById(R.id.imageView1); Log.d("KMC.updateCPL", TVti.toString()); try { //Get the first item - not part of the listview JSONObject jObject = jArray.getJSONObject(0); String title = jObject.getString("Title"); Log.d("KMC.updateCPL", title); //works TVti.setText(title); //does not work TVar.setText(jObject.getString("ArtistName")); TVal.setText(jObject.getString("AlbumName")); IV.setImageResource(R.drawable.noimage); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } ListView LV = (ListView) this.activity.findViewById(R.id.listView1); LV.setAdapter(new listAdapter(this.activity, jArray)); } </code></pre> <p>My layout:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;TextView android:textAppearance="?android:textAppearanceLarge" android:id="@+id/title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@+id/imageView1" android:text="@string/hello" android:layout_alignTop="@+id/imageView1" android:layout_alignParentRight="true" /&gt; &lt;TextView android:textAppearance="?android:textAppearanceSmall" android:id="@+id/artist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/title" android:layout_alignLeft="@+id/title" android:layout_alignParentRight="true" /&gt; &lt;TextView android:textAppearance="?android:textAppearanceSmall" android:id="@+id/album" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/artist" android:layout_alignLeft="@+id/artist" /&gt; &lt;ListView android:id="@+id/listView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/imageView1" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /&gt; &lt;ImageView android:id="@+id/imageView1" android:layout_width="90.0dip" android:layout_height="90.0dip" android:layout_marginLeft="5.0dip" android:layout_marginTop="5.0dip" android:layout_marginRight="5.0dip" android:layout_marginBottom="5.0dip" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>However, while i can log the result, TVti.setText(title); does not work as the text is not displayed.</p> <p>Anyone got an idea what the problem is?</p> <p>EDIT: Forget this, this isnt the problem. The problem is that the UpdateCPL method was not being called from the main thread.</p>
    singulars
    1. This table or related slice is empty.
    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