0
我修改的XML代碼,但它仍然是錯誤:我在Android中有一個「充氣異常」錯誤工作室
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:orientation="vertical"
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"
tools:context="com.example.android.miwok.NumbersActivity"/>
,這是java代碼..
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
public class NumbersActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_numbers);
ArrayList<String> words = new ArrayList<String>();
words.add(0, "one");
words.add(1, "two");
words.add(2, "three");
words.add(3, "four");
words.add(4, "five");
words.add(5, "six");
words.add(6, "seven");
words.add(7, "eight");
words.add(8, "nine");
words.add(9, "ten");
ArrayAdapter<String> itemsAdapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, words);
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(itemsAdapter);
}
}
android.view.InflateException: Binary XML file line #2: Error inflating class GridViewView
我已經更改爲ListView,但它仍然存在。
請給一些解決方案,我在Udacity Android課程。
請[編輯]你的問題發佈完整的堆棧跟蹤。 –
嘗試使用ListView清理項目 – user8256287
出於興趣 - 所有這些維都使用了定義和有效的? – Ewald