2012-04-01 3 views
0

これは問題を起こしているダイアログJavaファイルです。それは非常によく似ていますが、他のダイアログファイルでもうまく動作します。このダイアログは、別の進行状況ダイアログが終了したときに呼び出されるということです。もう1つは終了しますが、この新しいコードは開かれません(ただし、コードは実行されます)。理由はわかりません。アンドロイドにダイアログが表示されない理由は何ですか?

public class Response extends Dialog implements OnClickListener { 

    Button cpandclose; 
    EditText response; 
    Context context; 

    //Skapar dialog med About xml filen 
    public Response(Context context, String url) { 
     super(context); 
     /** 'Window.FEATURE_NO_TITLE' - Used to hide the title */ 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     /** Design the dialog in main.xml file */ 
     setContentView(R.layout.response); 

     cpandclose = (Button) findViewById(R.id.cpandclose); 
     cpandclose.setOnClickListener(this); 
     response = (EditText) findViewById(R.id.resposeurl); 
     response.setText("http://xxx.com/i/" + url); 
     this.context = context; 
     Log.d("Response Window: ", "running.."); 
    } 

    public void onClick(View v) { 
     if (v == cpandclose) { 
      ClipboardManager ClipMan = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); 
      ClipMan.setText(response.getText()); 
      dismiss(); 
     } 
    } 
} 

表示されませんダイアログのxml-file

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/responsetxt" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Response:" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <EditText 
     android:id="@+id/resposeurl" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <requestFocus /> 
    </EditText> 

    <Button 
     android:id="@+id/cpandclose" 
     android:layout_width="225dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:text="Copy and Close" /> 

</LinearLayout> 

バックグラウンドでいくつかのデータをアップロードし、それが終了していますとき、それはデータが文字列に戻って適用することにより、アプリ機能:

これは、現在のカメラオブジェクトとそれが呼び出す関数のresponseFromServerメソッドを呼び出します。

public void responseFromServer(String url) { 
Looper.prepare(); 
Response response = new Response(this, url); 
Log.d("response: ", url); 
response.show(); 
} 

これはプログラムを実行しますが、表示されるダイアログは表示されません。どのようにすることができますか?それは簡単な解決策かもしれないが、私はすべてを試したように感じる!

あなたのアドバイスとより良い知恵をお寄せいただきありがとうございます。

答えて

3

responseFromServer()ではなく、onCreateDialog()にダイアログを作成する必要があるためです。

+0

ありがとうございました。 :) – Ms01

+0

好奇心で、なぜあなたはこの答えを受け入れなかったのですか?宜しくお願いします。 – pouzzler

+0

これは機能しなかったためです。私はandroid devサイトのガイドラインに従いました。サーバーからデータを受け取ったときにダイアログが表示されません。私はあなたがそれを調べたいなら、私が帰っているときにもっと詳細を投稿することができます。 :) – Ms01

関連する問題