我的代码出现问题...... 以前,它工作,然后我在布局中添加了一些简单的线条,现在我有很多错误。我试图自己学习如何为我的学校图书馆做一个应用程序,所以我不是专业人士。 谢谢你的帮助。
此处的错误是"无法解决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);`
这里的错误是:Element LinearLayout没有必需的属性: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">
答案 0 :(得分:0)
试试这个
<?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>