2016-07-29 5 views
0

配列をリストに変換し、シャッフルメソッドを呼び出してから、同じ配列に戻してシャッフルしようとしています。ただし、何らかの理由でデータがシャッフルされていません。それは静的なのですか?私はエラーがない、それはちょうどシャッフルされません。ありがとう。配列がアンドロイドでシャッフルされていません

public static String IMGS[] = { 
      "http://i.imgur.com/F6WgOZg.jpg", 
      "https://images.unsplash.com/photo-1439546743462-802cabef8e97?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1441155472722-d17942a2b76a?q=80&fm=jpg&w=1080&fit=max&s=80cb5dbcf01265bb81c5e8380e4f5cc1", 
      "https://images.unsplash.com/photo-1437651025703-2858c944e3eb?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1431538510849-b719825bf08b?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1434873740857-1bc5653afda8?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1439396087961-98bc12c21176?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1433616174899-f847df236857?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1438480478735-3234e63615bb?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300", 
      "https://images.unsplash.com/photo-1438027316524-6078d503224b?dpr=2&fit=crop&fm=jpg&h=725&q=50&w=1300" 
    }; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_detail); 

     List<String> arr = Arrays.asList(IMGS); 
     Collections.shuffle(arr); 
     arr.toArray(IMGS); 

答えて

3

私はあなたがIMGS

List<String> arr = Arrays.asList(IMGS); 
    Collections.shuffle(arr); 
    IMGS = arr.toArray(IMGS); 
+0

に割り当てうーんそのそれでもシャッフルないようarr.toArrayのリターンを使用することを忘れてしまったと思います。 – Brandex07

+0

@ Brandex07この変更後にシャッフルする必要があります。 IDEで試しました –

+0

hmm私はideを再起動しようとします...エミュレータが更新されていない可能性があります – Brandex07

関連する問題