您好,登錄后才能下訂單哦!
要求:用Dialog對(duì)話框顯示一個(gè)列表,并實(shí)現(xiàn)其點(diǎn)擊效果
代碼:
private ListView lv_list; private String deleteName; private AlertDialog.Builder builder; private Dialog dialog; private void showDialog() { /** * 創(chuàng)建Dialog,參數(shù)為當(dāng)前環(huán)境與樣式。 */ 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("請(qǐng)選擇指派到其他班次的員工"); lv_list = (ListView) view.findViewById(R.id.lv_dialog_list); builder.setView(view); builder.setCancelable(false); // 設(shè)置適配器,適配器參數(shù)分別為:當(dāng)前環(huán)境、listview中的item、item中的textview、textview所需的數(shù)據(jù)數(shù)據(jù) lv_list.setAdapter(new ArrayAdapter<String>(Managr_BanCi_List.this, R.layout.listview_item, R.id.tv_listview_item, data_Delete)); // 為listview中的item設(shè)置點(diǎn)擊事件 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);// 手機(jī) intent.putExtra("pwd", deleteBanC_PeoPleName.pwd);// 密碼 intent.putExtra("biaoshi", biaoshi);// 員工轉(zhuǎn)移班次 startActivityForResult(intent, 10); } }); // 顯示 dialog = builder.show(); }
關(guān)閉:
dialog.dismiss();
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。