0

私が開発しているアプリでは、アラート ダイアログ ボックスにスピナーがあります。

スピナーは正常に動作しますが、配列をスピナーに追加するために次の行を追加すると、起動後数秒でアプリがクラッシュします。

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.newFileTypeArray, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    newFileType.setAdapter(adapter);

私は何を間違っていますか?

これらの Android スピナーも少し複雑なようです。Android のドキュメントを参照せずに作成方法を思い出すことはできないと思います。

4

2 に答える 2

1

Problem solved.

I realised that the following line:

final Spinner newfiletypespinner = (Spinner) findViewById(R.id.newfiletypespinner);

I had to change to:

final Spinner newfiletypespinner = (Spinner) newFileDialogInflated.findViewById(R.id.newfiletypespinner);

With "newFileDialogInflated" being the previously inflated view so I could have a custom AlertDialog view:

final View newFileDialogInflated = View.inflate(this, R.layout.newfileview, null);

But thanks for the help!

于 2010-09-06T01:41:48.950 に答える
0

スニペットから省略したのか、コードから省略したのかはわかりませんが、newFileTypeをスピナーとして初期化しますか?

Spinner newFileType = (Spinner)findViewById(R.id.newFileTypeSpinner);

または類似?初期化する前にアダプタを設定しようとしている場合は、それで説明できます。

于 2010-09-01T20:25:04.673 に答える