我遇到問題後,無處不在搜索到如何將警報對話元素或彈出元素存儲在變量中。在Intent中傳遞AlertDialog元素(Android)
例如, 在我的彈出窗口中,我通過php從json獲得了像Principal,Incharge和Teacher這樣的值。
不是我想要將Intent中的Selected Item移動到Intent中傳遞(Principal)。
我正在努力爲此。請幫忙 !
AlertDialog.Builder builderSingle = new AlertDialog.Builder(context);
builderSingle.setIcon(R.drawable.logo);
builderSingle.setTitle("Select One Recipent:-");
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(context,
android.R.layout.select_dialog_singlechoice);
for (i = 0; i < myData.length; i++) {
arrayAdapter.add(myData[i]);
selecteditem = myData[i]; /// Should be the selected item but its not i know
}
builderSingle.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String strName = arrayAdapter.getItem(which);
AlertDialog.Builder builderInner = new AlertDialog.Builder(context);
builderInner.setMessage(strName);
Intent intent = new Intent(context,send_communication_to.class);
intent.putExtra("Authoritytype", selecteditem);
context.startActivity(intent);
解釋你的問題。 – Jas
問題是,我想通過選擇的項目的彈出窗口例如**老師**到下一頁。我們可以實現這個 –
爲什麼你不能使用'意圖'? – Jas