Kent Sechrest Kent Sechrest - 3 months ago 8
Android Question

New to Android development- what does this line of XML mean?

I am new to programming and trying to learn android development with android studio. I updated Java and tried to update android SDK when it crashed. I finally got the Android SDK update fixed but now I have this error in an app I was working on. It's in the

activity_main.xml
file
The error says "cannot resolve this symbol:
MainActivity.java
"

Here's the line where the error shows up.

tools:context="com.example.android.justjava.MainActivity.java"


MainActivity.java
is red. I feel like it's directory tree issue, but I can't tell what the program wants so I can fix it.

Answer

Remove .java at the end, and make sure that MainActivity.java exists inside the package com.example.android.justjava.

What is the purpose of writing that line?

tools:context

This attribute is typically set on the root element in a layout XML file, and records which activity the layout is associated with (at designtime, since obviously a layout can be used by more than one layout). This will for example be used by the layout editor to guess a default theme, since themes are defined in the Manifest and are associated with activities, not layouts.

Source: http://tools.android.com/tech-docs/tools-attributes

Comments