0

This is structure what I'm using

<FrameLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <AbsoluteLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@+id/abs_layout">
            <ImageView    />
            <ImageView   />
    </AbsoluteLayout>

    <ImageView android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon"/>

</FrameLayout>

Above Structure work fine but when I used below structure gives error

<FrameLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon"/>

    <AbsoluteLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@+id/abs_layout">
            <ImageView    />
            <ImageView   />
    </AbsoluteLayout>
</FrameLayout>

Error Log:

10-14 10:35:54.134: E/AndroidRuntime(13044): FATAL EXCEPTION: main
10-14 10:35:54.134: E/AndroidRuntime(13044): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.d/com.example.d.DMainActivity}: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.AbsoluteLayout
10-14 10:35:54.134: E/AndroidRuntime(13044):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
10-14 10:35:54.134: E/AndroidRuntime(13044):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
Akarsh M
  • 1,629
  • 2
  • 24
  • 47
  • Absolute layout is deprecated from a long time.Use some other layout to achieve your requirement – Biraj Zalavadia Oct 14 '13 at 05:48
  • can you shown hows ur layout look like graphically then try to achieve this by some other way ? – Haresh Chhelana Oct 14 '13 at 05:58
  • @Haresh : Still I m just sort out this thing.. other way is this last option but i want to understand this problem first . hope you can understand – Akarsh M Oct 14 '13 at 06:00
  • I want to use drag and drop functionality in ABSLayout. I tried drag and drop in other layout but it not giving the o/p what I need @BirajZalavadia – Akarsh M Oct 14 '13 at 06:01
  • 1
    Code seems fine,Clean rebuild your project, if problem still persists delete R.java and rebuild again. – Jitender Dev Oct 14 '13 at 06:38
  • Can you please tell me the reason about this ... @Brontok – Akarsh M Oct 14 '13 at 06:44
  • 1
    There is a problem with Eclipse i.e. re-creating views, Some time there occurs problem in R.java as it has already defined a view in it. So it won't recognize whether a view is changed from say AbsoluteLayout to ImageView, It still thinks its still the same view. That is why clean and re-build works and the final solution is delete your R.java files so that it may create reference of views again. – Jitender Dev Oct 14 '13 at 07:08

0 Answers0