Thsi is my code:
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>
The null pointer error shows that in line:
editCategoryName.setText("Google is your friend.", TextView.BufferType.EDITABLE);
I don’t know why. Please help..
After
super.onCreate(savedInstanceState);this line you forget
setContentView(R.layout.<xml file name>)