Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm following the steps shown in this video:
http://www.youtube.com/watch?v=YeR7McJIltk[^]


so i created these three files as done in the video:

1-FlyOutContainer.java

Java
package com.example.FluOutexample.view.viewgroup;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

public class FlyOutContainer extends LinearLayout{
   private View menu;
   private View content;
	
   //Constants
   protected static final int menuMargin=150;
    	
   public enum MenuState{
      CLOSED,OPEN
   };
          
   //Position Informations attributes
   protected int currentContentOffset=0;
   protected MenuState menucurrentState=MenuState.CLOSED;
          
   public FlyOutContainer(Context context, AttributeSet att,int deffStyle){
      super(context,att,deffStyle); 
   }
   public FlyOutContainer(Context context, AttributeSet att){
      super(context,att); 
   } 

   public FlyOutContainer(Context context){
      super(context); 
   }
          
   @Override
   public void onAttachedToWindow(){
      super.onAttachedToWindow();
      this.menu=this.getChildAt(0);
      this.content=this.getChildAt(1);
      this.menu.setVisibility(View.GONE);
   }
          
   @Override
   protected void onLayout(boolean changed,int top,int bottom,int left,int right){
      if(changed)
      {
         this.calculateChilddimensions();
      }
      this.menu.layout(left, top, right+ menuMargin, bottom); 
        		  
      this.content.layout(left + this.currentContentOffset , top, right+ this.currentContentOffset, bottom);
   }
          
   public void toggleMenu(){
      switch(this.menucurrentState){
         case CLOSED:
        	   this.menu.setVisibility(View.VISIBLE);
        	   this.currentContentOffset  =this.getMenuWidth();
        	   this.content.offsetLeftAndRight(currentContentOffset);
        	   this.menucurrentState=MenuState.OPEN;
        	   break;
         case OPEN:
        	   this.content.offsetLeftAndRight(-currentContentOffset);
        	   this.currentContentOffset=0;
        	   this.menucurrentState=MenuState.CLOSED;
        	   this.menu.setVisibility(View.GONE);
        	   break;
      }
      this.invalidate();
   }
          
   private int getMenuWidth(){
      return this.menu.getLayoutParams().width;
   }
   public void calculateChilddimensions(){
      this.content.getLayoutParams().width=this.getWidth();
      this.content.getLayoutParams().height=this.getHeight();
      this.menu.getLayoutParams().width=this.getWidth() + menuMargin;
      this.menu.getLayoutParams().height=this.getHeight();
   }
}


2-SampleActivity.java

Java
package com.example.sampleactivity;

import com.example.FluOutexample.view.viewgroup.FlyOutContainer;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;

public class SampleActivity extends Activity {
   FlyOutContainer root;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //setContentView(R.layout.activity_sample);
    		
      this.root=(FlyOutContainer) this.getLayoutInflater().inflate(R.layout.activity_sample,null);
            
      this.setContentView(root);
   }
    
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.sample, menu);
      return true;
   }
    
    	
   public void toggleMenu(View v){
      this.root.toggleMenu();	
   }
}



3-sample_activity.xml

HTML
<com.example.FluOutexample.view.viewgroup.FlyOutContainer xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:removed="#FFF000" >


             <Button
            android:id="@+id/bt1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 1"
            android: önClick="toggleMenu" />
              <Button
            android:id="@+id/bt2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 2"
            android: önClick="toggleMenu" />
               <Button
            android:id="@+id/bt3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 3"
            android: önClick="toggleMenu" />

        </LinearLayout>

            <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:removed="#FF22FF"
                android:orientation="vertical" >

        <Button
            android:id="@+id/button_Toggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ToggleMenu"
            android: önClick="toggleMenu" />

           <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Toggle   Menu"/>

    </LinearLayout>


</com.example.FluOutexample.view.viewgroup.FlyOutContainer>


but when i run the application nothing shows
can anyone please help?
Posted
Updated 21-Sep-13 13:42pm
v3
Comments
ZurdoDev 21-Sep-13 23:39pm    
I would follow the link and see if the author has any updated code or contact information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900