}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private Fragment mContent;
/**
-
切换视图
-
@param fragment
*/
public void switchContent(Fragment fragment) {
mContent = fragment;
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, fragment).commit();
getSlidingMenu().showContent();
}
}
/2013.12.2_SlidingMenu_for_weibo/src/com/wwj/slidingmenu/demo/SampleListFragment.java
package com.wwj.slidingmenu.demo;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
/**
-
@author wwj 功能描述:列表Fragment,用来显示滑动菜单打开后的内容
*/
public class SampleListFragment extends ListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.list, null);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
SampleAdapter adapter = new SampleAdapter(getActivity());
adapter.add(new SampleItem(“登录”, R.drawable.login_logo));
adapter.add(new SampleItem(“疑问”, R.drawable.d_yiwen));
adapter.add(new SampleItem(“右哼哼”, R.drawable.d_youhengheng));
adapter.add(new SampleItem(“晕”, R.drawable.d_yun));
adapter.add(new SampleItem(“抓狂”, R.drawable.d_zhuakuang));
adapter.add(new SampleItem(“猪头”, R.drawable.d_zhutou));
adapter.add(new SampleItem(“做鬼脸”, R.drawable.d_zuoguilian));
adapter.add(new SampleItem(“左哼哼”, R.drawable.d_zuohengheng));
setListAdapter(adapter);
}
public class SampleAdapter extends ArrayAdapter {
public SampleAdapter(Context context) {
super(context, 0);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.row, null);
}
ImageView icon = (ImageView) convertView
.findViewById(R.id.row_icon);
icon.setImageResource(getItem(position).iconRes);
TextView title = (TextView) convertView
.findViewById(R.id.row_title);
title.setText(getItem(position).tag);
return convertView;
}
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Fragment newContent = null;
switch (position) {
case 0:
newContent = new MyFragment();
break;
case 1:
newContent = new MyFragment1();
break;
case 2:
newContent = new MyFragment2();
break;
case 3:
newContent = new MyFragment3();
break;
case 4:
newContent = new MyFragment4();
break;
case 5:
newContent = new MyFragment5();
break;
case 6:
newContent = new MyFragment6();
case 7:
newContent = new MyFragment7();
break;
}
if (newContent != null) {
switchFragment(newContent);
}
super.onListItemClick(l, v, position, id);
}
private void switchFragment(Fragment fragment) {
if (getActivity() == null) {
return;
}
if (getActivity() instanceof MainActivity) {
MainActivity fca = (MainActivity) getActivity();
fca.switchContent(fragment);
}
}
private class SampleItem {
public String tag;
public int iconRes;
public SampleItem(String tag, int iconRes) {
this.tag = tag;
this.iconRes = iconRes;
}
}
}
/2013.12.2_SlidingMenu_for_weibo/src/com/wwj/slidingmenu/demo/MyFragment.java
package com.wwj.slidingmenu.demo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/***
-
@author wwj
*/
public class MyFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.login, null);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public void onPause() {
super.onPause();
}
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**
[外链图片转存中…(img-qhsRjnUK-1710917578347)]
[外链图片转存中…(img-N6w4BRVl-1710917578348)]
[外链图片转存中…(img-vWB3J1hl-1710917578348)]
[外链图片转存中…(img-0ocXauGd-1710917578349)]文章来源:https://www.toymoban.com/news/detail-843232.html
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
[外链图片转存中…(img-oov4r3PO-1710917578349)]文章来源地址https://www.toymoban.com/news/detail-843232.html
到了这里,关于AndroidUI--SlidingMenu使用例子,在线面试指南的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!