侧滑菜单的实现方式(三):drawlayout

一主页面的布局




    
    

    

        
    



二左边fragent

public class LeftFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        TextView textView=new TextView(getContext());
        textView.setText("左边菜单");
        return textView;


    }
}

三主页面的代码

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //初始化左边菜单
        iniLeftMenu();
    }


    private void iniLeftMenu() {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.left_fragment,new LeftFragment())
                .commit();
    }
}

你可能感兴趣的:(侧滑菜单的实现方式(三):drawlayout)