【发布时间】:2018-07-04 18:53:29
【问题描述】:
我正在使用以下代码为 android 使用轮盘赌选择算法:
//int n=4;
//double [] weight = new double [n];
//weight[0]=9;
//weight[1]=8;
//weight[2]=10;
//weight[3]=1;
public void Roulette(double weight[],double max_weight){
int index=0;
while (true){
index= (int)(weight.length*Math.random());
if(Math.random()<weight[index]/max_weight) {break;}
}
Toast.makeText(getBaseContext(),"Chosen="+index,Toast.LENGTH_LONG).show();
}
是否可以使用 android studio 创建(图形和代码)如下图所示的内容?
【问题讨论】:
-
您可以通过编程方式为可绘制对象充气并用不同的颜色绘制它,但您需要一个 xml 来定义要绘制的图形的不同部分
-
public static void main(String [] args) {看起来不像 Android 代码。你确定吗? -
is it possible to create当然,这是可能的。为您创建它有什么问题?
标签: android roulette-wheel-selection