내 코드의 문제점은 창이 항상 기본적으로 열립니다., 그 이유는 알 수 없습니다. 분명히, 기본적으로 창 (아이)이 열리지 않기를 바란다. 사용자가 lv_schedule을 클릭 할 때만 창이 열립니다. 따라서 프래그먼트가로드되면 실제로 lv_schedule을보기 위해 먼저 패널을 슬라이드 아웃해야합니다.SlidingPaneLayout 구현시 창 항상 열림
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scheduledblocks_sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:id="@+id/ll_left_pane_scheduled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/lv_schedule"
android:layout_width="1000dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginRight="0dp"
/>
</LinearLayout>
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container_scheduledblocksslidingpanedetailview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp" />
이 자바 파일 :
이
은 XML입니다public class Fragment_allScheduledBlocks extends Fragment implements
View.OnClickListener, OnItemClickListener {
private Handler handler;
private ActionBarHelper mActionBar;
private Thread thread = new Thread();
public Fragment_allScheduledBlocks() {
}
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mLogger.printToLog(Constants.LOG_ENTRY,
" onCreateView of Fragment_scheduled_blocks.java",
Constants.TAG_ALL);
v = inflater.inflate(R.layout.fragment_scheduled_blocks, container,
false);
mSlidingLayout = (SlidingPaneLayout) v
.findViewById(R.id.scheduledblocks_sliding_pane_layout);
mSlidingLayout.setPanelSlideListener(new SliderListenerSchBlocks());
mSlidingLayout.openPane();
lv_scheduled = (ListView) v.findViewById(R.id.lv_scheduled);
lv_scheduled.setOnItemClickListener(this);
mActionBar = createActionBarHelper();
mActionBar.init();
return v;
}
/**
* This panel slide listener updates the action bar accordingly for each
* panel state.
*/
private class SliderListenerSchBlocks extends
SlidingPaneLayout.SimplePanelSlideListener {
@Override
public void onPanelOpened(View panel) {
mActionBar.onPanelOpened();
Log.v(Constants.TAG, "in onPanelOPened inside SliderListener");
getActivity().setTitle("LISTVIEW BLOCKS");
mPrefs.printAllMySharedPrefs(getActivity().getApplicationContext());
}
@Override
public void onPanelClosed(View panel) {
mActionBar.onPanelClosed();
Log.v(Constants.TAG, "in onPanelClosed inside SliderListener");
mPrefs.printAllMySharedPrefs(getActivity().getApplicationContext());
}
@Override
public void onPanelSlide(View panel, float slideOffset) {
// TODO Auto-generated method stub
super.onPanelSlide(panel, slideOffset);
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
private class ActionBarHelper {
public void init() {
}
public void onPanelClosed() {
}
public void onPanelOpened() {
}
public void onFirstLayout() {
}
public void setTitle(CharSequence title) {
}
}
/*
* Create a compatible helper that will manipulate the action bar if
* available.
*/
private ActionBarHelper createActionBarHelper() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// return new ActionBarHelperICS();
return new ActionBarHelper();
} else {
return new ActionBarHelper();
}
}
}