4
如果在用對話框回答選擇問題後,某人選擇了特定的答案,我希望通過對話框進行跟進。對話框打開另一個對話框
在這個例子中,如果人選擇'Choice1',那麼應該打開另一個對話框來詢問更多問題。
下面我有以下部分代碼:
private void openDialog1()
{
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Select Choice");
builder.setSingleChoiceItems(ChoiceLists.listofchoices,-1,new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
ccRewardDialog.dismiss();
String finalString = "";
if((ChoiceLists.listofchoices[item].equals("Choice1")) || (ChoiceLists.listofchoices[item].equals("Choice2")))
{
openDialog2();
}
TextView tv1 = (TextView) getActivity().findViewById(R.id.tv1);
finalString = ChoiceLists.strRewards[item];
if(!RESULT.equals("")) //RESULT being a global value
{
finalString = finalString + "-" + RESULT;
RESULT = "";
}
tv1.setText(tv1.getText() + finalString + "\n");
}
});
dialog1 = builder.create();
dialog1.show();
}
private void openDialog2()
{
LayoutInflater li = LayoutInflater.from(getActivity());
View promptView = li.inflate(R.layout.reward_detail_prompt, null);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(promptView);
final EditText userInput = (EditText) promptView.findViewById(R.id.etRewardDetail);
builder.setCancelable(false);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
RESULT = userInput.getText().toString();
}
});
builder.setNegativeButton("Cancel",new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
RESULT = ""; //RESULT being a global value
}
});
}
如果我不能做這種方式。你會如何去做這件事?提前致謝。我繼續學習更多,因爲我在這方面努力......感謝所有幫助
您可以從... HTTP以下鏈接找到它:// stackoverflow.com/questions/8424757/display-android-dialog-on-top-of-another/42471023#42471023 –