Thsi的的setText是我的代碼空指針:當的EditText
EditText editCategoryName, editBrandName;
private ArrayAdapter<String> myAdapter1, myAdapter2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// mylist = new ArrayList<HashMap<String, String>>();
// mylist2 = new ArrayList<HashMap<String, String>>();
myList1 = new ArrayList<String>();
myList2 = new ArrayList<String>();
editCategoryName = (EditText)findViewById(R.id.editCategoryName);
editBrandName = (EditText)findViewById(R.id.editBrandName);
editCategoryName.setText("Google is your friend.", TextView.BufferType.EDITABLE);
<EditText
android:id="@+id/editCategoryName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="請輸入分類名稱"
android:singleLine="true" >
</EditText>
<TextView
android:id="@+id/textSpinnerBrand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="hint" />
<Spinner
android:id="@+id/spinnerBrand"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/editBrandName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="hint"
android:singleLine="true" >
</EditText>
空指針錯誤顯示,在行:
editCategoryName.setText("Google is your friend.", TextView.BufferType.EDITABLE);
我不知道爲什麼。請幫助..
'setContentView(...);' – 2012-03-22 05:19:44