1

I'm having problems with my code... Before, it worked, then I added some simple lines in the layout and now I have lots of erros. I'm trying to learn by myself how to do an app for my schools libray so I'm no pro. Thanks for any help.

The error here is "Cannot resolve R"

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

    majorOb = (Spinner) findViewById(R.id.spinnerMaj);
    yearOb = (Spinner) findViewById(R.id.spinnerYear);
    semesterOb = (Spinner) findViewById(R.id.spinnerSem);
    classOB = (Spinner) findViewByID(R.id.spinnerClass);
    button1 = (Button) findViewById(R.id.button1);
    tv1 = (TextView) findViewById(R.id.textview1);
    Resources res = getResources();
    array1 = res.getStringArray(R.array.Books);`

The error here is: Element LinearLayout doesnt have the required attribute: layout_height adn layout_width

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.marcosbiblio.projetofinal.MainActivity">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

1 Answers1

0

Try this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.marcosbiblio.projetofinal.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"></LinearLayout>
Sumit Pathak
  • 472
  • 2
  • 7
  • 23