開いているフラグメントを閉じてメイン アクティビティに戻るにはどうすればよいですか?
public class MainActivity extends SlidingFragmentActivity {
public SlidingMenu sm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Main layout
setContentView(R.layout.activity_main);
setBehindContentView(R.layout.menu_frame);
// SlidingMenu
sm = getSlidingMenu();
sm.setFadeDegree(0.35f);
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
sm.setBehindOffset(120);
sm.setMode(SlidingMenu.LEFT_RIGHT);
// Left menu
getSupportFragmentManager().beginTransaction()
.replace(R.id.menu_frame, new LeftMenuFragment()).commit();
// Right menu
getSlidingMenu().setSecondaryMenu(R.layout.menu_frame_second);
getSupportFragmentManager().beginTransaction()
.replace(R.id.menu_frame_two, new RightMenuFragment()).commit();
}
public class LeftMenuFragment extends Fragment{
ImageView img;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_left_menu, container,
false);
this.inflater = inflater;
img = (ImageView) view.findViewById(R.id.test);
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//RETURN TO MAIN ACTIVITY
}
});
}
return view;
}
縦滑りは可能ですか?