我有以下代码。当我把它放在ACTION_DOWN中时它可以工作,当我把它放在ACTION_UP中时它没有,我做错了什么?
var item_name
答案 0 :(得分:0)
尝试在ACTION_UP
的情况下添加button1
。
也许ACTION_CANCEL
的父级拦截了TouchEvent。孩子将获得ACTION_UP
而不是 button1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) {
if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
//it works here
// progress = ProgressDialog.show(ExampleAct.this,"Processing...","Preparing file", true);
} else if (event.getAction() == android.view.MotionEvent.ACTION_UP
||event.getAction() == MotionEvent.ACTION_CANCEL
) {
//It doesn't work here
progress = ProgressDialog.show(ExampleAct.this,"Processing...","Preparing file", true);
}
return true;
}
});
using (WebClient wc = new WebClient())
{
var json = wc.DownloadString("//api call here");
jsonData = JsonConvert.DeserializeObject<List<T>>(json);
}