<https://lh4.googleusercontent.com/-kxbaryQn3-Y/UQpeCHgJO3I/AAAAAAAAE6c/Trd_NNGOU4w/s1600/flags+app+last+bug.jpg>


// after the user guesses a correct flag, load the next flag
>
>    private void loadNextFlag() 
>
>    {
>
>       // get file name of the next flag and remove it from the list
>
>       String nextImageName = quizCountriesList.remove(0); // 10 imgs: 
>> remove one by one
>
>       correctAnswer = nextImageName; // update the correct answer to 
>> compare with country choosen
>
>
>>       answerTextView.setText(""); // clear answerTextView 
>
>
>>       // display the number of the current question in the quiz
>
>       questionNumberTextView.setText(
>
>          getResources().getString(R.string.question) + " " + 
>
>          (correctAnswers + 1) + " " + 
>
>          getResources().getString(R.string.of) + " 10");
>
>
>>       // extract the region from the next image's name
>
>       String region = nextImageName.substring(0, 
>> nextImageName.indexOf('-'));
>
>
>>       // use AssetManager to load next image from assets folder
>
>       AssetManager assets = getAssets(); // get app's AssetManager
>
>       InputStream stream; // used to read in flag images
>
>
>>       try
>
>       {
>
>          // get an InputStream to the asset representing the next flag
>
>          stream = assets.open(region + "/" + nextImageName + ".png");
>
>          
>
>          // load the asset as a Drawable and display on the flagImageView
>
>          Drawable flag = Drawable.createFromStream(stream, nextImageName);
>
>          flagImageView.setImageDrawable(flag);                       
>
>       } // end try
>
>       catch (IOException e)  
>
>       {
>
>          Log.e(TAG, "Error loading " + nextImageName, e);
>
>       } // end catch
>
>
>>       // clear prior answer Buttons from TableRows
>
>       for (int row = 0; row < buttonTableLayout.getChildCount(); ++row)
>
>          ((TableRow) buttonTableLayout.getChildAt(row)).removeAllViews();
>
>
>>       Collections.shuffle(fileNameList); // shuffle file names
>
>
>>       
>
>       
>
>       // put the correct answer at the end of fileNameList 
>
>       int correct = fileNameList.indexOf(correctAnswer);   
>
>       fileNameList.add(fileNameList.remove(correct)); 
>
>       
>
>       
>
>       // resolve big ru names - start
>
>       
>
>       int[] sizeWordCountries = new int[9];  // 10   
>
>       
>
>       for (int i = 0; i < 9; i++)  
>
>       { 
>
>       sizeWordCountries[i]=fileNameList.get(i).length();
>
>       }
>
>       //sizeWordCountries[9]=correctAnswer.length();
>
>       
>
>       int mLength=0;
>
>       
>
>       for (int row = 0; row < guessRows; row++) 
>
>       {
>
> int max1=findLargest(sizeWordCountries);
>
> String temp1=fileNameList.get(3*guessRows);
>
> String temp2=fileNameList.get( max1 );
>
> fileNameList.set(3*guessRows, temp2);
>
> fileNameList.set(max1, temp1);
>
>
>> mLength = sizeWordCountries[max1];
>
> sizeWordCountries[max1]=0;
>
>
>>       
>
>       } 
>
>       int column1;// = random.nextInt(3); // pick random column
>
>       if (mLength < correctAnswer.length())
>
>       {//column=0
>
>       column1 = 0;
>
>       } else 
>
>       {//column=1, 2
>
>       column1 = 1+random.nextInt(2); // pick random column
>
>       
>
>       }
>
>       
>
>       
>
>       // resolve big ru names - end
>
>
>>
>>       // get a reference to the LayoutInflater service
>
>       LayoutInflater inflater = (LayoutInflater) 
>> getSystemService(Context.LAYOUT_INFLATER_SERVICE);
>
>
>>       // add 3, 6, or 9 answer Buttons based on the value of guessRows
>
>       for (int row = 0; row < guessRows; row++) 
>
>       {
>
>          TableRow currentTableRow = getTableRow(row);
>
>
>>          // place Buttons in currentTableRow
>
>          for (int column = 0; column < 3; column++) 
>
>          {
>
>             // inflate guess_button.xml to create new Button
>
>             Button newGuessButton = (Button) 
>> inflater.inflate(R.layout.guess_button, null);
>
>       
>
>             // get country name and set it as newGuessButton's text
>
>             String fileName = fileNameList.get((row * 3) + column);
>
>             newGuessButton.setText(getCountryName(fileName));  
>
>             
>
>             // register answerButtonListener to respond to button clicks
>
>             newGuessButton.setOnClickListener(guessButtonListener);
>
>             currentTableRow.addView(newGuessButton);
>
>          } // end for
>
>       } // end for
>
>       
>
>       // randomly replace one Button with the correct answer
>
>       int row = random.nextInt(guessRows); // pick random row
>
>       //int column = random.nextInt(3); // pick random column
>
>       int column = column1;
>
>       
>
>       TableRow randomTableRow = getTableRow(row); // get the TableRow
>
>       String countryName = getCountryName(correctAnswer);
>
>       ((Button)randomTableRow.getChildAt(column)).setText(countryName);  
>
>       
>
>       
>
>       
>
>    } // end method loadNextFlag
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to