1

So I am building a project but my R.Java got deleted somehow (reasons?) and it shows R can't b resolved into a variable,what to do now? Also no main.out.xml is there in my layout so no problems there.

Another problem is with my XML file in the two lines at bottom it shows these errors respectively:

1 - Error parsing XML no element found(No idea what this means.)

2 - XML document structure must start end end within the same entity.(Can't find an unclosed tag,help me!)

Here's my troubled XML file's code:

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/imgthing"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10" >
    </EditText>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="@drawable/imgthing"
        android:orientation="horizontal"
        android:weightSum="100" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="50"
            android:gravity="center"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="50"
            android:gravity="center"
            android:text="TextView" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/imgthing"
        android:orientation="horizontal"
        android:weightSum="2" >

        <RadioGroup
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical" >

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="RadioButton" />

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="RadioButton" />

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="RadioButton" />
        </RadioGroup>

        <RadioGroup
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical" >

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="RadioButton" />

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="RadioButton" />

            <RadioButton
                android:id="@+id/radioButton1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="RadioButton" />
        </RadioGroup>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="TextView" />

        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button" />
    </LinearLayout>
    </LinearLayout>

Also, when I view this in Graphical layout, then no radio buttons are visible in it. And if it matters, I have a white background in it. EDIT:The second error is gone, reposted the code, it has only the first error.

15
  • Clean and build your project... Use ctrl+a and ctrl+shift+f to format your code .. You might find some minor syntax errors .. Commented Jan 3, 2014 at 12:15
  • What do you mean by build project? you mean retyping the code again or something else? Sorry, if this is a stupid question because I'm new to android development. Commented Jan 3, 2014 at 12:19
  • No.. no... First format your code like I said.. Then select your project and in eclipse do --> Project--> Clean. Commented Jan 3, 2014 at 12:21
  • Hey, I would recommend reading about the basics again, and not writing any further code. It will be a bit boring, but it will stand to you. It's too easy to patch something up without getting the concepts. Building, cleaning etc your project are things you need to know about. As I said it's a bit boring, but well worth it. You could have ended up retyping all your code again for starters! I hope it doens't sound like I'm being harsh, I learned all this stuff VERY BADLY due to getting quick fixes and solutions online and it has cost me MONTHS of work now that it has caught up with me! Commented Jan 3, 2014 at 12:23
  • 1
    @RossC Alright,I will do the same and get back to you on that. But can I continue making projects at the same time? Commented Jan 3, 2014 at 13:03

1 Answer 1

3

You forgot to close your parent layout, just close it and you will be ok!

Add at the end of the file

 </LinearLayout>

Hope this helps!

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

7 Comments

Thanks! Putting </LinearLayout> and saving+cleaning ,fixed all the errors. But still,I can't see my radio buttons in Graphical Layout. Some help please!
@AmanB. Is your third linear layout orientation correct? It's set to horizontal. And you are using weight sum, you set the weight only for RadioGroups. What about the other childs?
Yeah it worked all my radio buttons are in a vertical line now,anyways forget it..I am off this project. I guess I will read the documentation again. Thank you!
@AmanB. Do not give up, I'm sure you'll master it in no time!
How to learn this? because each time I read documentation I get more confused,so complicated words!! How did you do it?
|

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.