2012-02-19 22 views
0

のロード中に、私は、サーバーからデータを取得するために、AsyncTaskを使用して、それは次のようにロード中に画面を表示したいのです:ここアンドロイド:表示画面

private class GetListTask extends AsyncTask { 
    protected void onPreExecute() { 
      Intent intent = new Intent(); 
       intent.setClass(Start.this, Wait.class); 
       startActivity(intent); 
    } 

    protected Bitmap doInBackground(Object... args) { 

//私は、サーバー

からデータを取得します
 d = getImageFromURL(Start.valuesArray[Integer.parseInt(Value)][7]); 
     Bitmap bitmap = ((BitmapDrawable) d).getBitmap(); 
     double ratio = (double) bitmap.getWidth()/(double) bitmap.getHeight(); 
     Bitmap scaled = Bitmap.createScaledBitmap(bitmap, width, (int) (width/ratio), true); 
     return scaled; 
    } 

    protected void onPostExecute(Object objResult) { 
     if (objResult != null && objResult instanceof Bitmap) { 
      Bitmap result = (Bitmap) objResult; 

      im.setImageBitmap(result); 
     } 
    } 
} 

ここで、onPostExecute()では、この「待機」画面を再度非表示にする必要がありますが、どうすればできますか? 助けてくれてありがとう!

+0

あなたは 'onPreExcute()'で始まる 'Activity'でいくつかの作業をしていますか?それとも単なるイメージですか? – Luksprog

+0

そのちょうどイメージ。 – user934779

答えて

1

の代わりに、別のアクティビティを開始するあなたの代わりに... preExecute()に今

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

    <!-- Your actual layout. width & height fill_parent --> 

    <ImageView 
     android:id="@+id/wait_image" 
     android:layout_width="fill_parent" 
     android:visibility="gone" 
     android:layout_height="fill_parent" 
     android:src="@drawable/wait_screen" 
    /> 
</FrameLayout> 

が待機ImageViewのと非表示を示しPopupDialogであなたのイメージを示し、onPostExecute

+0

ありがとう、私はそれを行います! – user934779

1

使用このレイアウトでそれを閉じることができます実際のレイアウト

postExecute()画像を非表示にする&は実際のレイアウトを示します。

+0

現在のレイアウトを非表示にするにはどうすればよいですか?どのように私は正しく待っている画像ビューを表示するのですか? – user934779

+0

は 'serVisibility()'メソッドを使います。たとえば、 'findViewById(R.id.wait_image).setVisibility(View.VISIBLE)'はimageViewを表示し、 'findViewById(R.id.your_layout_id).setVisibility(View.GONE)'はレイアウトを隠します。 – Shaiful

関連する問題