Custom layout weird behaviour
I have created a custom framelayout that contains multiple views inside
it. When the layout is clicked, some animations are done inside the
layout. I have created two instances of the layout in my XML as below:
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="19dp"
android:orientation="vertical" >
<com.example.MyProj
android:id="@+id/frame1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="19dp"
android:layout_marginRight="28dp"
android:clickable="true" >
</com.example.MyProj>
<com.example.MyProj
android:id="@+id/frame2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:clickable="true" >
</com.example.MyProj>
</LinearLayout>
Now the weird behavior here is that, after defining these layouts in my
main class, when I click on the first layout, animation is happening on
the second layout ie, when i click on frame1, frame 2 is animating. The
second layout is responding fine when clicked. So the layout which is
defined the latest is getting animated. The layout which got defined the
last is not getting animated.
This is how I have defined the layouts in my main class:
final MyProj fl = (MyProj) findViewById(R.id.frame1);
final MyProj fl1 = (MyProj) findViewById(R.id.frame2);
fl.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
fl.reset();
fl.animation();
}
});
fl1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
fl.reset();
fl1.animation();
}
});
Could someone please explain why these layouts are behaving in this way?
Thanks in advance.
No comments:
Post a Comment