0

私は2つのイメージビュー(切断されているときは赤、接続されているときは緑)を表示するViewFlipperを持っていますが、奇妙な結果があります.接続すると赤い画像が表示されることがあります.red-green-赤を返します(接続している場合でも)。JAVAコードは次のとおりです。

public void onRegistrationDone(String localProfileUri, long expiryTime) {

                        updateStatus("Enregistré au serveur.");
                        Log.d("SUCCEED","Registration DONE");

                        final ViewFlipper flipper = (ViewFlipper)findViewById(R.id.flipper);
                        flipper.postDelayed(new Runnable() {
                        public void run() {
                        flipper.showNext();
                            }
                        },2000);}

ビューは赤い画像で開始され、接続すると (2 秒後)、通常は次の画像が表示されます。

何が問題なのですか?どうもありがとうございました。

編集: XML ファイル (ハンドラー)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<TextView
  android:id="@+id/sipLabel"
  android:textSize="20sp"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  />
  <ImageView android:id="@+id/status"  android:layout_below="@id/sipLabel" 
  android:layout_width="fill_parent" android:scaleType="center"
        android:layout_height="fill_parent" android:layout_weight="0.35" android:gravity="center"

         />
        </LinearLayout>
4

1 に答える 1

3

私はそれを別の方法で行います。別の画像(赤/緑)を表示するだけの場合は、ImageViewUIコントロールを使用してその画像を表示します。また、表示の更新を遅らせるには、ハンドラーを使用できます。このようなもの:

public void onRegistrationDone(String localProfileUri, long expiryTime) 
{
    updateStatus("Enregistré au serveur.");
    Log.d("SUCCEED","Registration DONE");

    mRegistered = true;
    mRegistrationUpdateHandler.removeCallbacks(handleUpdateStatus);
    mRegistrationUpdateHandler.postDelayed(handleUpdateStatus, 2000);
}

public void onRegistrationLost()
{
    mRegistered = false;
    mRegistrationUpdateHandler.removeCallbacks(handleUpdateStatus);
    mRegistrationUpdateHandler.postDelayed(handleUpdateStatus, 2000);
}

private Runnable handleUpdateStatus = new Runnable() 
{     
    public void run()
    {
        ImageView statusImageDisplay = (ImageView)findViewById(R.id.statusImage);
        if (mRegistered)
        {
            statusImageDisplay.setImageDrawable(getResources().getDrawable(R.drawable.imageGreen));
        else
        {
            statusImageDisplay.setImageDrawable(getResources().getDrawable(R.drawable.imageRed));
        }
    }
};  
于 2011-05-11T06:46:36.163 に答える