ViewGroup isn't showing

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

ViewGroup isn't showing

Postby s4b3r » Sun Aug 23, 2009 6:29 pm

hi guys,
I'm quite new to Android and now I'm playing around with views.

There is a ViewGroup containing 2 inflated Views.
getChildCount() returns 2, so the ChildViews were added correctly,
but getHeight() and getWidth() return 0 and there is nothing on the screen.

maybe someone could help me:

Code: Select all
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View root = View.inflate(this, R.layout.main, null);
        View v = View.inflate(this, R.layout.day, null);
       
        // intialize rootViewGroup
        ViewGroup rootViewGroup = new ViewGroup(this) {
         @Override
         protected void onLayout(boolean changed, int l, int t, int r, int b) {
            // TODO Auto-generated method stub
         }
      };
      
        rootViewGroup.addView(root,200,200);
        rootViewGroup.addView(v,50,125);
        setContentView(rootViewGroup);
    ...
User avatar
s4b3r
Freshman
Freshman
 
Posts: 4
Joined: Thu Aug 13, 2009 2:55 pm

Top

Postby mad.dogg » Sun Aug 23, 2009 8:50 pm

This
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.          @Override
  2.          protected void onLayout(boolean changed, int l, int t, int r, int b) {
  3.             // TODO Auto-generated method stub
  4.          }
  5.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

is the problem.
Read this, it will make things a bit more clear :)
If it's boring it ain't heavy enough!
mad.dogg
Developer
Developer
 
Posts: 42
Joined: Tue May 20, 2008 2:18 pm
Location: Bulgaria

Postby s4b3r » Tue Aug 25, 2009 2:32 pm

thx for the info,
had to read the text more than once to understand it,
but I just had to measure() and layout() the children. :roll:
User avatar
s4b3r
Freshman
Freshman
 
Posts: 4
Joined: Thu Aug 13, 2009 2:55 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests