Here is the code of my program which i used to implement the slide panel, but i want to make list view items in it. So how do i do it? Please help. Thanks in advance! MainActivity Code:
// Slide the Panel
menuRightButton = (ImageView) findViewById(R.id.menuViewButton);
menuRightButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!isExpanded) {
isExpanded = true;
// Expand
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction();
fragmentTransaction.replace(R.id.menuPanel,
new LeftMenuFragment());
fragmentTransaction.commit();
new ExpandAnimation(slidingPanel, panelWidth1,
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.55f, 0, 0.0f, 0, 0.0f);
} else {
isExpanded = false;
// Collapse
new CollapseAnimation(slidingPanel, panelWidth1,
TranslateAnimation.RELATIVE_TO_SELF, 0.55f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f, 0, 0.0f,
0, 0.0f);
}
}
});
Leftmenufragement.java
//Left Menu
public class LeftMenuFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.leftmenu, container, false);
}
}
leftmenu.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2C323F"
>
<ListView
android:id="@+id/listview2"
android:layout_width="250dp"
android:layout_height="550dp"
android:background="#32394A"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"/>
Update Your LeftMenuFragment As :
public class LeftMenuFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.leftmenu, container, false);
ListView menuList = (ListView) view.findViewById(R.id.listview2);
String[] items = { "Home", "Setting"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, items);
menuList .setAdapter(adapter);
return view;
}
}