1
我想創建一個對話框警報,因爲它顯示在android中,當我們點擊一個Wi-Fi連接到Wi-Fi時。我創建了一個對話框提示,但沒有顯示所有的textview和edittext。請幫助如何在對話框警報中添加多個文本視圖和編輯文本
這裏是我的代碼
AlertDialog.Builder password = new AlertDialog.Builder(context);
password.setTitle("Connect to Network");
final TextView ssid = new TextView(context);
ssid.setText(wifiScanList.get(position).SSID);
password.setView(ssid);
final TextView bssid=new TextView(context);
bssid.setText(wifiScanList.get(position).BSSID);
password.setView(bssid);
final TextView capab=new TextView(context);
capab.setText(wifiScanList.get(position).capabilities);
password.setView(capab);
final EditText pass =new EditText(context);
password.setView(pass);
password.setPositiveButton("Connect", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
checkPassword= pass.getText().toString();
finallyConnect(checkPassword, position);
dialog.dismiss();
}
});
password.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
AlertDialog passdialog = password.create();
passdialog.show();
請發表意見xml代碼 – 2014-09-20 10:35:32
@rogerthatcode我沒有使用xml代碼來創建對話框警報。 – user3853169 2014-09-20 10:42:14