am new to android. i have small issue in mouse motion use, i don't know to handle . when scroll up or down in mouse to change the button value when reach the particular value stop the mouse motion or not change the values. Please suggest me and advance thanks...
My Activity
public class MainActivity extends Activity {
Button btn;
int x,f;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn=(Button)findViewById(R.id.btn);
btn.setOnGenericMotionListener(new OnGenericMotionListener() {
@Override
public boolean onGenericMotion(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:
if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f)
{
x=Integer.parseInt(btn.getText().toString());
f=x+5;
btn.setText(""+f);
if(x==10)// this condition mouse scroll but not change btn value.
{
btn.settext("10");
}
}
else
{
x=Integer.parseInt(btn.getText().toString());
f=x-5;
btn.setText(""+f);
}
}
return false;
}
});
}}