1. Hot New Devices! HTC One M9 | Samsung Galaxy S6 | LG G4

can you debug?


  1. lse123

    lse123 Well-Known Member

    [HIGH]

    private List<String> fileNameList; // flag file names
    int[] sizeWordCountries = new int[9]; // 10

    for (int i = 0; i < 9; i++)
    {
    sizeWordCountries=(fileNameList.get(i)).length(); // here error: syntax error : insert "(" to complete expression
    }[/HIGH]can you debug?... here error: syntax error : insert "(" to complete expression

    Advertisement
  2. myrecek

    myrecek Active Member

    Post the whole code. This piece seems to be ok. I think the problem is somewhere else.
  3. lse123

    lse123 Well-Known Member

    here is all function...[HIGH] // 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=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
    [/HIGH]
  4. lse123

    lse123 Well-Known Member

    here is a screenshot

    Attached Files:

  5. myrecek

    myrecek Active Member

    Please post the whole code in that particular java source file. I mean starting at line 1 ending with last line.

    Many times in case of missing some block marking symbol (e.g. '{', '}', '(', ')' ) the compiler doesn't correctly recognize where the block should end and shows you an error on some line that hasn't anything to do the with the actual problem.

    Your loadNextFlag() method seems to be correct so the problem must lie somewhere else. A simple way to find it is to iteratively remove blocks of code (in your case you can start with the body of method loadNextFlag) and see if the syntax error disappears.
  6. lse123

    lse123 Well-Known Member

    thia heps from log... in .metadata/
  7. lse123

    lse123 Well-Known Member

    thanks for this, i removed this function saved java file, and after reinserted function intact and problem disappears... any hint why now OK, why was appeared?

    other alerts in screen shot required fix or, not so required???

Share This Page