2017-05-24 3 views
-1

私は自分のダイアログ内にGridView Galleryを作成しました。このギャラリーにはいくつかのページがありますが、それぞれのために私は分離されたダイアログを作成します。このすべてのダイアログ(ギャラリーページ)は、現在の進行状況(例えば、4/12ページにある)と写真(各ページごとに異なるイメージをロードする)によって異なります。私はすべてのページのための新しいダイアログを作成することは実用的ではないと思っていますが、ただ1つのダイアログでどうすればいいですか?私のダイアログコードのダイアログ内のすべてのコンテンツを更新します。

ワン:

public void threeChoice() 
    { 
     Collections.sort(photoList = imageReader(photoDir,"1008")); 
     inflater = this.getLayoutInflater(); 

     // Dialog layout 
     v = inflater.inflate(R.layout.dialog_choice, null); 

     progressDialog = (ProgressBar)v.findViewById(R.id.progressBar); 
     //progressDialog = new ProgressBar(mContext); 
     progressDialog.setMax(7); 
     progressDialog.setProgress(3); 


     gV = (GridView) v.findViewById(R.id.gridView); 

     // GridAdapter (Pass context and files list) 
     GridAdapter adapter = new GridAdapter(this, photoList); 

     // Set adapter 
     gV.setAdapter(adapter); 



     final AlertDialog.Builder builder2 = new AlertDialog.Builder(this); 
     builder2.setTitle("Album Page: 1008"); 

     builder2.setView(v); 
     builder2.setPositiveButton("NEXT", new DialogInterface.OnClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int which) 
      { 
       NextPage(); //<-- go to next page 
      } 
     }).setNegativeButton("BACK", new DialogInterface.OnClickListener() { 
      @Override 
      public void onClick(DialogInterface dialog, int which) 
      { 
       PreviousPage(); //<-- Back to previous page 
      } 
     }); 

     gV.setOnItemClickListener(new AdapterView.OnItemClickListener() 
     { 
      public void onItemClick(AdapterView<?> parent, View v, int position, long id) 
      { 
       Intent intent = new Intent(getApplicationContext(), PhotoDetails.class); 
       intent.putExtra("image", photoList.get(position)); 
       startActivity(intent); 
      } 
     }); 

     builder2.setCancelable(false); 
     final AlertDialog dialog = builder2.create(); 
     dialog.show(); 
    } 

答えて

0

あなたはNextPage(View v);PreviousPage(View v);NextPage();PreviousPage();の署名を変更する必要があります。次に、ダイアログレイアウトvでそれらを呼び出すことができ、このレイアウトを関数から直接更新することができます。

+0

しかし、私はimageViewer関数を呼び出して、更新アダプタなどのような残りのものを行う必要がある場合、どのように(View v)アイテム(ImageView)とちょうどgridView 2番目のレイアウト1を持っている –

+0

vすべてが含まれていませんダイアログに表示されるビューは? – Firerazzer

関連する問題