How To Synchronize The Drawable State Of Two Views
In Android I have an EditText and a Button next to the EditText, and whenever I press on one I would like the other to appear in the same state as well. I tried putting android:cli
Solution 1:
I think you want android:focusable="true"
in your RelativeLayout instead of clickable. Im not sure what you mean by "How can I make my views transparent to touch events so they pass down to the parent?" When you click on the EditText you want the Buttons onClick() to get called?
Solution 2:
Consider trapping all input to the edit text and button and redirecting the event to a common view controller, in this case, a common method. Then update both the edit text and button in the common method (a view controller). For the edit text you will need to trap both on touch and on click by creating a handler for both events as in:
// EDIT TEXT ON TOUCH HANDLER
editTextPassword.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
SynchViews(); // view controller
break;
}
return true;
}
});
// EDIT TEXT ON Click HANDLER (No touch screen)
editTextPassword.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
SynchViews(); // view controller
}
});
Post a Comment for "How To Synchronize The Drawable State Of Two Views"