Thursday, November 24, 2011

[android-developers] OnClick not being handled by CompundView with EditText and ImageButton

Hi,

I've tried to create a simple compound view with an EditTExt and a
button, but when I try to register a onClickListener on the
imagebutton it doesn't seem to get called. Here is the code:

This code is in the constructor of my CompoundView which extends
FrameLayout:


...
final View root =
LayoutInflater.from(getContext()).inflate(R.layout.root_layout, this,
true);
setClickable(true);

imageButton= (ImageButton) root.findViewById(R.id.btnMyButton);
imageButton.setImageResource(android.R.drawable.ic_btn_icon);
editText = (EditText) root.findViewById(R.id.myEditText);


imageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Log.i("CompoundView", "Click event was detected.");


}
});

}


I can see the edit text and button but when I click on the button I
don't see any logs. Anyone know what I need to do to make the
onClickListsner work?


regards,
Dennis

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate