您好,登錄后才能下訂單哦!
要求:用Dialog對話框顯示一個列表,并實現其點擊效果
代碼:
private ListView lv_list; private String deleteName; private AlertDialog.Builder builder; private Dialog dialog; private void showDialog() { /** * 創建Dialog,參數為當前環境與樣式。 */ builder = new AlertDialog.Builder(this); View view = LayoutInflater.from(Managr_BanCi_List.this).inflate( R.layout.dialog_list, null); TextView tv_text = (TextView) view.findViewById(R.id.tv_dialog_list); tv_text.setText("請選擇指派到其他班次的員工"); lv_list = (ListView) view.findViewById(R.id.lv_dialog_list); builder.setView(view); builder.setCancelable(false); // 設置適配器,適配器參數分別為:當前環境、listview中的item、item中的textview、textview所需的數據數據 lv_list.setAdapter(new ArrayAdapter<String>(Managr_BanCi_List.this, R.layout.listview_item, R.id.tv_listview_item, data_Delete)); // 為listview中的item設置點擊事件 lv_list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { biaoshi = true; Intent intent = new Intent(Managr_BanCi_List.this, Manager_Add.class); DeleteBanC_PeoPleName deleteBanC_PeoPleName = (DeleteBanC_PeoPleName) treeMap_Delete .get(data_Delete[position]); intent.putExtra("companyId", getIntent().getExtras().getString("id")); deleteName = deleteBanC_PeoPleName.name; intent.putExtra("name", deleteBanC_PeoPleName.name);// 姓名 intent.putExtra("dapart", deleteBanC_PeoPleName.dapart);// 部門 intent.putExtra("id", deleteBanC_PeoPleName.id);// 員工 intent.putExtra("loginname", deleteBanC_PeoPleName.loginname);// 登錄用戶名 intent.putExtra("phone", deleteBanC_PeoPleName.phone);// 手機 intent.putExtra("pwd", deleteBanC_PeoPleName.pwd);// 密碼 intent.putExtra("biaoshi", biaoshi);// 員工轉移班次 startActivityForResult(intent, 10); } }); // 顯示 dialog = builder.show(); }
關閉:
dialog.dismiss();
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。