Re: [問題] 請問如何在另一個class中使用alertdialog
※ 引述《laugher (.。oO)》之銘言:
: public void showItemCategory(Context ct) {
: String[] stra_item_category =
: getResources().getStringArray(R.array.stra_item_category);
: AlertDialog.Builder dlg_item_category = new AlertDialog.Builder(ct);
: dlg_item_category.setTitle(getString(R.string.str_dlg_item_category_title));
: dlg_item_category.setNeutralButton(getString(R.string.str_cancel), null);
: dlg_item_category.setItems(stra_item_category,
: new DialogInterface.OnClickListener() {
: public void onClick(DialogInterface dialog, int index) {
: showItemList(index);
: }
: }
: );
: dlg_item_category.show();
: }
我找到問題了
上面的函式裡的getResources或是getString等會讀取xml資源的都要改成
ct.getResources或ct.getString
因為目前的activity仍是RoamingMap
感謝版友的幫忙
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.72.155
→
05/31 14:15, , 1F
05/31 14:15, 1F
→
05/31 14:15, , 2F
05/31 14:15, 2F
→
05/31 14:16, , 3F
05/31 14:16, 3F
→
05/31 14:23, , 4F
05/31 14:23, 4F
→
05/31 14:59, , 5F
05/31 14:59, 5F
→
05/31 15:00, , 6F
05/31 15:00, 6F
→
05/31 15:00, , 7F
05/31 15:00, 7F
→
05/31 15:31, , 8F
05/31 15:31, 8F
→
05/31 15:31, , 9F
05/31 15:31, 9F
→
05/31 15:41, , 10F
05/31 15:41, 10F
→
05/31 15:43, , 11F
05/31 15:43, 11F
→
05/31 16:11, , 12F
05/31 16:11, 12F
→
05/31 19:04, , 13F
05/31 19:04, 13F
→
06/02 19:16, , 14F
06/02 19:16, 14F
→
06/02 19:16, , 15F
06/02 19:16, 15F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):