我试图让一个触摸监听器触发,但我无法让它工作。有人看到我做错了吗?谢谢!
public class FindEventsActivity extends Activity implements LocationListener, OnTouchListener {
//lots of other code up here
private void getFromCityState() {
LayoutInflater inflater = LayoutInflater.from(this);
View view = inflater.inflate(R.layout.city_state_entry, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
setContentView(R.layout.city_state_entry);
city = (EditText) findViewById(R.id.city);
state = (Spinner) findViewById(R.id.state_spinner);
Button submitButton = (Button) findViewById(R.id.submitButton);
System.err.println("About to create onClickListener");
submitButton.setOnTouchListener(this);
return null;
}
public boolean onTouch(View view, MotionEvent event) {
System.err.println("inside onTouch");
}
}
我的第一个 println 出现了,但我的第二个没有出现。它必须是我设置 onTouchListener 的上下文,但我不知道如何更改它。