smackライブラリに基づいてチャットアプリケーションを作成しようとしています。logcatはすべてを正しく送受信するため、私の問題はこのライブラリとは何の関係もないと思います。私の問題は、メッセージを受信しても表示されないことです。以下は、私がテキストを表示するために使用している方法です。
public void TextCreating(String message) {
Log.d("START", "Method Excution started.");
layout = (LinearLayout) findViewById(R.id.layoutLinear);
LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
tv = new TextView(this);
tv.setLayoutParams(lparams);
tv.setText(message);
tv.setTextColor(Color.WHITE);
Log.d("STARTED", "Text color OK.");
layout.addView(tv);
Log.d("STARTED", "Text didsplayed.");
}
このコードの平和は、受信したメッセージとして実行されます。これらの受信メッセージは、PacketListenerと呼ばれるリスナーを介して処理されます。この受け取り部分は正常に機能しています。このリスナーでは、上記のTextCreatingメソッドを呼び出すと、tv.setTextColor(Color.WHITE)まで実行されます。最後の行は実行されません。これの理由は何ですか?どうすればこの問題を解決できますか?前もって感謝します :)
編集 :
<?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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chat Room"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Chat History :" />
<LinearLayout
android:id="@+id/layoutLinear"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:orientation="vertical"
android:background="#000000"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp" >
</LinearLayout>
<EditText
android:id="@+id/editTextMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/buttonSend"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>