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
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;
protected static final int menuMargin=150;
public enum MenuState{
CLOSED,OPEN
};
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
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);
this.root=(FlyOutContainer) this.getLayoutInflater().inflate(R.layout.activity_sample,null);
this.setContentView(root);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.sample, menu);
return true;
}
public void toggleMenu(View v){
this.root.toggleMenu();
}
}
3-sample_activity.xml
<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?