1

I follow the tutorial from Capturing images from camera and setting into listview in android. However, I get

Error:(42, 50) error: cannot find symbol variable array

  String imageTempName;
    String[] imageFor;

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

        listView = (ListView) findViewById(R.id.captureList);
        getSets = new ArrayList<GetSet>();
       imageFor = getResources().getStringArray(R.array.imageFor);
        for (int i = 0; i < 3; i++) {

            GetSet inflate = new GetSet();
            // Global Values
            inflate.setUid(String.valueOf(i));

            inflate.setLabel("Image");
            inflate.setHaveImage(false);
            inflate.setSubtext(imageFor[i]);
            inflate.setStatus(true);

            getSets.add(inflate);
        }
        customImageAdapter = new CustomImageAdapter(getSets, MainActivity.this);
        listView.setAdapter(customImageAdapter);
    }

What's wrong here?

10
  • At which line getting issue? Commented Nov 17, 2015 at 16:30
  • Post your resource file where you store string array Commented Nov 17, 2015 at 16:30
  • @404notfound I follow this Commented Nov 17, 2015 at 16:32
  • @ρяσѕρєяK imageFor = getResources().getStringArray(R.array.imageFor); Commented Nov 17, 2015 at 16:32
  • Dear downvoters, please let me know what's I'm doing wrong here Commented Nov 17, 2015 at 16:36

1 Answer 1

4

I cheched your link. This tutorial is missing array declaration -> No one array is declared in string resources - > Your error happen!

Add this to strings.xml

<string-array name="imageFor">
    <item>1</item>
    <item>2</item>
    <item>2</item>
</string-array>

Where 1, 2 , 3 are your strings. In this case probably they are image urls.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, I' ve been finding this for more than half hour and you saved me ^^
... or arays.xml. Or any other name you like, what what it matters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.