发布网友 发布时间:2022-04-22 14:35
共4个回答
热心网友 时间:2023-11-09 06:14
public boolean onTouchEvent(android.view.MotionEvent event) {
int x = event.getX();
int y = event.getY();
多点触摸时 假如是第i个点
int x = event.getX(i);
int y = event.getY(i);
坐标就是 P(x,y)
}
热心网友 时间:2023-11-09 06:14
SharedPreferences share = getSharedPreferences("userPhoneNum",MODE_WORLD_WRITEABLE);
//可以
Editor edit = share.edit();
edit.putString("name", "dyc");
edit.putBoolean("flag", true);
edit.commit();
读成功!
System.out.println(share.getString("name", ""));
System.out.println(share.getBoolean("flag", false));
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="name">dyc</string>
<boolean name="flag" value="true" />
</map>
热心网友 时间:2023-11-09 06:15
MotionEvent中的方法:
getRowX:触摸点相对于屏幕的坐标
getX: 触摸点相对于按钮的坐标
热心网友 时间:2023-11-09 06:16
mGallery.setOnTouchListener(new OnTouchListener(){
//@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_MOVE){
float x = event.getX();
float y = event.getY();
}
return false;
}
});