我正在使用ontouch事件,但我遇到的问题是它调用down事件但它是nt调用move事件或UP事件检查以下代码
public class DragNewActivity extends Activity implements OnTouchListener {
private float X;
private float Y;
private int width;
private int height;
private CharSequence s;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.d("D","D");
TextView tv1 = (TextView)findViewById(R.id.tv1);
TextView tv2 = (TextView)findViewById(R.id.tv2);
tv1.setOnTouchListener(this);
//tv2.setOnTouchListener(this);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
//int action = event.getAction();
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d("DOWN","DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d("MOVE","MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d("UP","UP");
X = …Run Code Online (Sandbox Code Playgroud) 在一个每次面试的问题中,我被问到"你如何根据他们在考试中的总得分对十亿学生的名单进行排序?学生从1-1B和标记范围的移动数量为10-100 ".虽然任何排序算法都可以,但有效的排序算法是什么?
我刚刚完成了斐波纳契系列算法的迭代版本.我发现以下代码
int Fibonacci(int n)
{
int f1 = 0;
int f2 = 1;
int fn;
for ( int i = 2; i < n; i++ )
{
fn = f1 + f2;
f1 = f2;
f2 = fn;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的脑海里提出了一个愚蠢的问题.上面的函数添加了两个先前的数字并返回第三个数字,然后为下一次迭代准备好变量.怎么会这样呢."返回一些系列,这是前三个数字的总和"我们如何更改上面的代码来找到这样的数字.u