我有這樣的代碼:如何把一個EditText的對話框?
<EditText
android:id="@+id/etC"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/amount_credits"
android:inputType="number"
android:imeOptions="actionDone"
android:singleLine="true" />
和
AlertDialog.Builder creditsBox = new AlertDialog.Builder(this);
edC = (EditText) findViewById(R.id.etC);
creditsBox.setView(edC); //THIS LINE MAKES THE APP CRASH
creditsBox.setMessage("Enter amount of credits")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
}
});
AlertDialog creditsBoxC = creditsBox.create();
creditsBoxC.show();
現在我不明白問題出在哪裏。任何人都可以幫助我嗎?謝謝。
什麼是錯誤..? – JoxTraex