Help Addview to AbsoluteLayout

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Help Addview to AbsoluteLayout

Postby vibe » Sat Sep 26, 2009 12:56 pm

Hi,
I am trying to simply add a view to the current displayed absolutelayout , but when i use mainLayout.addview the subview is never shown.

The mainview displayed is load as follow :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. mainview = View.inflate(this, R.layout.main, null);
  3.  
  4. mainlayout=(AbsoluteLayout)mainview.findViewById(R.id.mainLayout);
  5.  
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4



Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4.  
  5.  
  6. <AbsoluteLayout android:id="@+id/mainLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Theme.MainView"><ImageView android:layout_width="wrap_content" android:id="@+id/ImageView01" android:layout_height="wrap_content" android:src="@drawable/mainview320x480v" android:layout_x="0dip" android:layout_y="0dip"></ImageView>
  7.  
  8.  
  9.  
  10. <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:drawingCacheQuality="high" android:src="@drawable/bt_arrow_left" android:layout_x="5dip" android:layout_y="363dip" android:background="@drawable/bt_arrow_left_x" android:id="@+id/btnEvLeft"></ImageButton>
  11.  
  12. <ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/bt_arrow_right" android:layout_x="205dip" android:layout_y="363dip" android:background="@drawable/bt_arrow_right_x" android:id="@+id/btnEvRight"></ImageButton>
  13.  
  14. </AbsoluteLayout>
  15.  
  16.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


I want the activeventview to be add to the mainview at runtime at a special position (x,y) (0,300);

The activeventview xml

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"   android:layout_width="320dip" android:id="@+id/ActivEventLayout" android:layout_height="150dip" android:visibility="visible" android:background="@drawable/topbannergray">
  2.  
  3. <ImageView android:layout_height="105dip" android:layout_width="105dip" android:layout_x="9dip" android:layout_y="18dip" android:id="@+id/imgCEventType" android:src="@drawable/ev_fix_radar105x105" android:visibility="visible"></ImageView>
  4.  
  5. <TextView android:text="@+id/TextView01" android:layout_x="130dip" android:layout_y="20dip" android:layout_height="64dip" android:layout_width="132dip" android:id="@+id/lblCEvent" android:capitalize="none" android:enabled="true"></TextView>
  6.  
  7. <TextView android:text="@+id/TextView01" android:id="@+id/lblDist" android:layout_x="130dip" android:layout_y="75dip" android:layout_width="132dip" android:layout_height="34dip" android:visibility="visible"></TextView>
  8.  
  9. <TextView android:text="@+id/TextView01" android:enabled="false" android:layout_x="130dip" android:layout_y="104dip" android:layout_width="132dip" android:layout_height="24dip" android:id="@+id/lblCEventTS"></TextView>
  10.  
  11. </AbsoluteLayout>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4


activeventview is declared as follow

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. ActivEventView =View.inflate(this, R.layout.activeventview,null);
  3.  
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


when i want to add ActivEventView to mainview i use :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 mainlayout.addView(ActivEventView);
  3.  
  4.                 //((ViewGroup) mainview).addView(ActivEventView,320,150);
  5.  
  6.                 ActivEventView.bringToFront();
  7.  
  8.                
  9.  
  10.                 mainlayout.invalidate();
  11.  
  12.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


The issue is that the ActivEventView is never displayed, and i do not understand why

Please Help !

- How to add a subview to the mainview at a dedicated position ?
- How to display the subview on screen ?

Many thanks
Vincent
vibe
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jun 19, 2009 1:55 pm

Top

Postby mangaluve » Sat Sep 26, 2009 3:23 pm

Perhaps you can do something like

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mainlayout.addView(ActivEventView, new AbsoluteLayout.LayoutParams(width, height, x, y));
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
mangaluve
Experienced Developer
Experienced Developer
 
Posts: 82
Joined: Mon Mar 23, 2009 8:59 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests