Androidプログラミング質問スレ Part30
■ このスレッドは過去ログ倉庫に格納されています
0424デフォルトの名無しさん
2013/03/19(火) 00:39:03.68情報をひっぱってきて、
AlertDialogの setItems(CharSequence[] items
に入れようと思っています。
今は以下のように実装しているのですが、
もっとスマートな書き方はありますでしょうか。
Cursorのclose()などは省略しています
// レコードの数を取得する
Cursor cursor = db.qurey("table", new String[]{"Name"}, "_ID Like '%'" null, null, null, null);
int count = cursor.getCount();
// レコードの数と同数のString配列を作成
String[] items = new String[count];
// レコードの内容をString配列にコピー
for (int i=0; i<count; i++) {
items[i] = cursor.getString(cursor.getColumnIndex("Name"));
cursor.moveToNext();
}
// アラートダイアログを表示
new AlertDialog.Builder(Hoge.this)
.setItems(items, new DialogInterface.OnClickListener....
宜しくお願いします。
■ このスレッドは過去ログ倉庫に格納されています