我正在尝试创建一个按钮,当按钮被释放时,它会添加1或任何数字.我的目标是创建一个屏幕上的光标键控制器来移动按钮/位图.以下代码仅在按下时添加1.如何让它连续计算?
谢谢你的帮助
package s.apps.kontroler;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.TextView;
public class Test extends Activity implements OnTouchListener {
Button up;
TextView text;
int countup;
boolean isDown = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
up = (Button) findViewById(R.id.button1);
text = (TextView) findViewById(R.id.textView1);
up.setOnTouchListener(this);
}
public boolean onTouch(View arg0, MotionEvent event) {
// TODO Auto-generated method stub
int i = event.getAction();
if (i …Run Code Online (Sandbox Code Playgroud)