1
Sir、 私はボタンのキーを使って作業しています。たとえば、マウスカーソルをボタンに移動すると5、マウスのスクロールを使用してsetOnGenericMotionListenerイベントに移動します。例:5は、マウススクロールに依存して値を増減するように変更されていますが、マウスカーソルポイントの任意の場所を移動したいのですが、マウスのスクロールイベントを使用してsetOnGenericMotionListenerイベントを設定し、 ?あなたはタッチイベントを検出するために、このメソッドを使用してはならないボタンクリックしてマウススクロール機能を使用したOnGenericMotionListenerイベント
活動
public class MainActivity extends Activity {
Button button;
int x,f;
@SuppressLint("NewApi") @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=(Button)findViewById(R.id.button1);
button.setOnGenericMotionListener(new OnGenericMotionListener() {
@Override
public boolean onGenericMotion(View v, MotionEvent event) {
// TODO Auto-generated method stub
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:
if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f)
{
x=Integer.parseInt(button.getText().toString());
f=x+5;
button.setText(""+f);
}
else
{
x=Integer.parseInt(button.getText().toString());
f=x-5;
button.setText(""+f);
}
}
return false;
}
});
}}