【发布时间】:2013-12-06 10:08:57
【问题描述】:
需要有关如何实现仅在选中另一个活动中的某个复选框时才显示的按钮的帮助/提示。
例如: 在一个选择你自己的冒险故事应用中
编辑片段活动:如果您希望片段中的按钮随机选择一个选项,您可以选中一个复选框。
如何使按钮仅在选中此复选框时弹出?
这是我创建的 randomChoice 方法。只需要上面的提示。提前致谢。
/**
* This method takes in an Array list of choices. It returns a random story
* fragment ID of a possible fragment that the current story fragment might
* go to.
*
* Example: If there is a fragment that has choices a,b,c, each of them
* leading to different fragments through toGoToStoryFragmentID. This method
* will then choose one of these possible choices at random and return that
* fragment ID.
*
* @param Choices
* An array list of choice objects containing all the possible
* choices of the fragment.
* @return The next story fragment ID that the randomChoice chose out of the
* possible choices.
*/
public static int randomChoice(ArrayList<Choice> choices) {
int ChoiceListSize = choices.size();
Random rand = new Random();
int randomIndexNumber = rand.nextInt(ChoiceListSize);
Choice chosenChoice = choices.get(randomIndexNumber);
return chosenChoice.getStoryFragmentID();
【问题讨论】:
-
在哪里可以找到解决方案,如果您能分享答案,那将非常有用
标签: android android-intent checkbox android-activity android-fragmentactivity