Eoeclient源代碼分析---SlidingMenu的使用

Eoeclient源代碼分析及代碼凝視html

使用滑動菜單SlidingMenu,單擊滑動菜單的不一樣選項,可以經過ViewPager和PagerIndicator顯示相應的數據內容。java


0  BaseSlidingFragmentActivity.javaandroid

主要函數:app

(1)showMenu()異步

/** * Opens the menu and shows the menu view.*/ide

    public void showMenu() {函數

       showMenu(true);佈局

    }學習

 

(2)showContent()this

/**Closes the menu and shows the above view. */

    public void showContent() {

       showContent(true);

    }

 

(3)toggle()

/**Toggle the SlidingMenu. If it is open, it will be closed, and viceversa.*/

    public void toggle() {

       toggle(true);

    }

 

    /**

     * Toggle the SlidingMenu. If it is open, itwill be closed, and vice versa.

     *

     * @param animate true to animate thetransition, false to ignore animation

     */

    public void toggle(booleananimate) {

       if (isMenuShowing()) {

           showContent(animate);

       } else {

           showMenu(animate);

       }

    }

(4)

//設置SlidingMenu使用的佈局

    publicvoid setBehindContentView(int id) {

       setBehindContentView(getLayoutInflater().inflate(id,null));

    }

 

    public void setBehindContentView(View v) {

       setBehindContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));

    }

    public void setBehindContentView(View v, LayoutParams params) {

       mHelper.setBehindContentView(v, params);

    }

    //獲取與該Acitivity相關的SlidingMenu對象

    public SlidingMenu getSlidingMenu() {

       returnmHelper.getSlidingMenu();

    }

 

1.   behind_sldingmenu.xml 滑動菜單的部分頁面佈局文件

滑動菜單主要由一個標題佈局(@layout/behinf_title)、菜單選項列表佈局和兩個本身定義圖形button等控件元素組成

<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#dadada"

    android:orientation="vertical">

   

    <!--sliding menu layout -->

    <includelayout="@layout/behind_title"/>

 

    <ListView

       android:id="@+id/behind_list_show"

       android:layout_width="match_parent"

       android:layout_height="match_parent"

       android:layout_gravity="top"

       android:layout_marginBottom="@dimen/list_margin_height"

       android:layout_marginTop="@dimen/title_height"

       android:divider="@drawable/dis_behind_side"

       android:listSelector="#0fff"

       android:cacheColorHint="#0000">

</ListView>

</FrameLayout>

 

2.   初始化滑動菜單

private SlidingMenu sm;

// [start]初始化函數

private void initSlidingMenu() {

//設置滑動菜單的佈局文件

        setBehindContentView(R.layout.behind_slidingmenu);

        // 獲取滑動菜單對象並設置外觀屬性customize the SlidingMenu

        sm = getSlidingMenu();

        sm.setShadowWidthRes(R.dimen.shadow_width);

        sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);

        // sm.setFadeDegree(0.35f);

        sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

        sm.setShadowDrawable(R.drawable.slidingmenu_shadow);

        //sm.setShadowWidth(20);

        sm.setBehindScrollScale(0);

}

 

3.   顯示菜單:

(1)單擊主界面左上角的LinearLayout控件

//  fromabove_title.xml  -- > pop up slidingmenu   (showMenu() )

      llGoHome = (LinearLayout) findViewById(R.id.Linear_above_toHome);

@Override

    public void onClick(View v) {

        // TODO Auto-generated method stub

        switch (v.getId()) {

            case R.id.Linear_above_toHome:

                showMenu();

                break;

}

}

(2)單擊手機的菜單選項

@Override

public boolean onKeyDown(int keyCode, KeyEventevent) {

else if (keyCode == KeyEvent.KEYCODE_MENU) {

 

            if (sm.isMenuShowing()) {

                toggle();

            } else {

                showMenu();

            }

        }

}

 

4. 設置填充滑動菜單中列表項數據的適配器

4.1 behind_list_show.xml (每一個列表項的佈局)

每一個列表項(子菜單選項)由一個ImageView(子菜單圖標)和TextView(子菜單名稱)組成

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="@dimen/behind_list_height"

    android:orientation="horizontal"

    android:background="@drawable/back_behind_listitem_style">

    <ImageView

       android:id="@+id/imageview_behind_icon"

       android:layout_width="wrap_content"

       android:layout_height="match_parent"

       android:src="@drawable/dis_menu_blog"

       android:scaleType="fitCenter"

       android:layout_marginLeft="10dp"

       android:layout_marginRight="10dp"/>

    <TextView

       android:id="@+id/textview_behind_title"

       android:layout_width="wrap_content"

       android:layout_height="wrap_content"

       android:layout_gravity="center_vertical"

       android:textColor="#666"

       android:textSize="@dimen/behind_list_text_size"/>

</LinearLayout>

4.2定義getData函數獲取填充列表項的數據List

private List<Map<String, Object>> getData() {

        List<Map<String, Object>>list = new ArrayList<Map<String, Object>>();

        //社區精選

        Map<String, Object> map = new HashMap<String,Object>();

        map.put(LIST_TEXT, getResources().getString(R.string.menuGood));

        map.put(LIST_IMAGEVIEW, R.drawable.dis_menu_handpick);

        list.add(map);

        //新聞資訊

        map = new HashMap<String, Object>();

        map.put(LIST_TEXT, getResources().getString(R.string.menuNews));

        map.put(LIST_IMAGEVIEW, R.drawable.dis_menu_news);

        list.add(map);

        //學習教程

        map = new HashMap<String, Object>();

        map.put(LIST_TEXT, getResources().getString(R.string.menuStudio));

        map.put(LIST_IMAGEVIEW, R.drawable.dis_menu_studio);

        list.add(map);

        //社區博客

        map = new HashMap<String, Object>();

        map.put(LIST_TEXT, getResources().getString(R.string.menuBlog));

        map.put(LIST_IMAGEVIEW, R.drawable.dis_menu_blog);

        list.add(map);

        return list;

    }

4.3定義列表項數據填充適配器

SimpleAdapter lvAdapter = new SimpleAdapter(this, getData(),

                R.layout.behind_list_show,new String[]{LIST_TEXT,

                LIST_IMAGEVIEW},

                new int[]{R.id.textview_behind_title,

                        R.id.imageview_behind_icon}) {

            @Override

            publicView getView(int position, View convertView, ViewGroupparent) {

                View view = super.getView(position,convertView, parent);

              //假設是當前選中的子菜單項

                if (position ==mTag) {

             //設置新的背景圖片  標識該菜單選項被選中

               view.setBackgroundResource(R.drawable.back_behind_list);

               lvTitle.setTag(view);//綁定當前選中的子菜單選項到lvTitle

                } else {

                   view.setBackgroundColor(Color.TRANSPARENT);

                }

                return view;

            }

       };

 

5.  單擊滑動菜單中的列表項 啓動不一樣的ViewPager

(1)NavigationModel  類的定義

package cn.eoe.app.entity;

public class NavigationModel {

    private Stringname;

    //做爲惟一標識符 newsblog wiki 方便於每個頁面請求相相應的地址

    private Stringtags;

    public NavigationModel(String name1,String tags1){

       this.name = name1;

       this.tags = tags1;

    }

}

 

(2)建立NavigationModel 對象,並加入四個子菜單相應的數據(name,tag)

private List<NavigationModel> navs;

 

private void initNav() {

        navs = new ArrayList<NavigationModel>();

        NavigationModel nav1 =new NavigationModel(getResources().getString(

                R.string.menuGood),"");

        NavigationModel nav2 =new NavigationModel(getResources().getString(

                R.string.menuNews), Constants.TAGS.NEWS_TAG);

        NavigationModel nav3 =new NavigationModel(getResources().getString(

                R.string.menuStudio),Constants.TAGS.WIKI_TAG);

        NavigationModel nav4 =new NavigationModel(getResources().getString(

                R.string.menuBlog),Constants.TAGS.BLOG_TAG);

        Collections.addAll(navs, nav1, nav2, nav3, nav4);

    }

(3)初始化列表項數據

MainActivity.java

initialListView(){}
lvAdapter = new SimpleAdapter(this, getData(),

                R.layout.behind_list_show,new String[]{LIST_TEXT,

                LIST_IMAGEVIEW},

                new int[]{R.id.textview_behind_title,

                        R.id.imageview_behind_icon});

lvTitle.setAdapter(lvAdapter);

(4)列表項單擊事件監聽函數

lvTitle.setOnItemClickListener(new OnItemClickListener() {

            @Override

            public void onItemClick(AdapterView<?> parent,View view,

                                    int position,long id) {

                NavigationModel navModel = navs.get(position);

                mAboveTitle.setText(navModel.getName());

                current_page = navModel.getTags();

                if (lvTitle.getTag() !=null) {

                    if (lvTitle.getTag() == view) {

//假設本次單擊的子菜單選項(view)和上一次選擇的子菜單選項(lvTitle.getTag())一樣,則直接顯示當前子菜單項相應的內容

                        MainActivity.this.showContent();

                        return;

                    }

                  //若果不一樣樣,又一次將原來菜單選項的背景色改成透明

                    ((View) lvTitle.getTag())

                           .setBackgroundColor(Color.TRANSPARENT);

                }

                lvTitle.setTag(view);//又一次綁定新的子菜單選項到lvTitle上

             //設置新的背景圖片  標識該菜單選項被選中

               view.setBackgroundResource(R.drawable.back_behind_list);

                imgQuery.setVisibility(View.VISIBLE);

              //依據選擇的不一樣子菜單選項運行不一樣的異步任務,顯示相應的數據內容

                switch (position) {

                    case 0:

                       imgQuery.setVisibility(View.GONE);

                        newMyTask().execute(topDao);

                        break;

                    case 1:

                        newMyTask().execute(newsDao);

                        break;

                    case 2:

                        newMyTask().execute(wikiDao);

                        break;

                    case 3:

                        new MyTask().execute(blogsDao);

                        break;

                }

            }

       });

 

6. 分離出來的模板樣例

在MainActivity中顯示選中的滑動菜單選項的名稱

(1) main.xml (MainActivity)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    
    
      
    <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/sso_topbar"
        >
        <ImageButton 
            android:layout_marginLeft="5dip"
            android:layout_centerVertical="true"
            android:id="@+id/imgbtn_top_left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/v5_0_1_flipper_head_flip"/>
        <TextView 
            android:layout_toRightOf="@id/imgbtn_top_left"
            android:id="@+id/tv_top_center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/tv_top_center"
            android:textColor="@color/whilte"
            android:layout_centerVertical="true"
            android:layout_marginLeft="25dip"
            
            />
        <ImageButton 
            android:id="@+id/imgbtn_top_right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/feed_refresh_arrow_pressed"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="5dip"/>
    </RelativeLayout>
    
    <TextView
        android:id="@+id/show_submenu_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</LinearLayout>

(2)fragment_left_bottom.xml (滑動菜單的佈局文件)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/renren_news_first_image_bg"
    android:orientation="vertical" >
    <!-- 頂部頭像,姓名。標籤 -->
    <include layout="@layout/left_bottom_top" />
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            <!-- 常用 -->
            <TextView
                android:id="@+id/left_tv_commom"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="3dip"
                android:paddingLeft="20dip"
                android:paddingTop="3dip"
                android:text="@string/left_bottom_commom"
                android:textColor="@color/whilte" />
                     
           <ImageView
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/v5_0_1_divider_new"/>
           <!-- 常用列表 --><!-- 常用列表與不少其它列表使用同一個item佈局 本身定義適配器 -->
           <com.pps.myrenren.custom.MyListView 
               android:id="@+id/listview_common"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:cacheColorHint="#00000000"
               android:divider="@drawable/v5_0_1_divider_line_new"/>
            <TextView
                android:id="@+id/left_tv_more"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="3dip"
                android:paddingLeft="20dip"
                android:paddingTop="3dip"
                android:text="@string/left_bottom_more"
                android:textColor="@color/whilte" />
           <ImageView
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/v5_0_1_divider_new"/>
           <!-- 不少其它列表 -->
           <com.pps.myrenren.custom.MyListView  
               android:id="@+id/listview_more"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:cacheColorHint="#00000000"
               android:divider="@drawable/v5_0_1_divider_line_new"/>
         <!--     <TextView
                android:id="@+id/left_tv_recommend"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="3dip"
                android:paddingLeft="20dip"
                android:paddingTop="3dip"
                android:text="@string/left_bottom_recommend"
                android:textColor="@color/whilte" />
           <ImageView
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/v5_0_1_divider_line_new"/>
     
          
           <ListView 
               android:id="@+id/listview_recommend"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:cacheColorHint="#00000000"
               android:divider="@drawable/v5_0_1_divider_new"/>
           <TextView
                android:id="@+id/left_tv_app"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="3dip"
                android:paddingLeft="20dip"
                android:paddingTop="3dip"
                android:text="@string/left_bottom_app"
                android:textColor="@color/whilte" />
           
           <ImageView
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/v5_0_1_divider_line_new"/>
           
           <ListView 
               android:id="@+id/listview_app"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:cacheColorHint="#00000000"
               android:divider="@drawable/v5_0_1_divider_new"/>  -->
           <TextView
                android:id="@+id/left_tv_setting"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="3dip"
                android:paddingLeft="20dip"
                android:paddingTop="3dip"
                android:text="@string/left_bottom_setting"
                android:textColor="@color/whilte" />       
           <ImageView
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:background="@drawable/v5_0_1_divider_new"/>
           <com.pps.myrenren.custom.MyListView  
               android:id="@+id/listview_setting"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:cacheColorHint="#00000000"
               android:divider="@drawable/v5_0_1_divider_line_new"/>
        </LinearLayout>
    </ScrollView>

</LinearLayout>

(3) menu_frame.xml  滑動菜單佈局文件(裝載Fragment的FrameLayout容器)
<?

xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/menu_frame" android:layout_width="match_parent" android:layout_height="match_parent" />

(4) MainActivity.java

Key:在Activtiy中實現在(5)中[LeftBottomFragment.java]定義的回調方法

package com.pps.myrenren.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageButton;
import android.widget.TextView;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;


public class MainActivity extends SlidingFragmentActivity implements LeftBottomFragment.SLMenuListOnItemClickListener{
	private ImageButton imgbtn_top_left;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.main);
		
		imgbtn_top_left=(ImageButton)this.findViewById(R.id.imgbtn_top_left);
		imgbtn_top_left.setOnClickListener(new OnClickListener() {			
			@Override
			public void onClick(View v) {
				/*Tip1:	Toggle the SlidingMenu. If it is open, it will be closed, and vice versa.*/
				toggle();	
			}
		});
		//Initial Sliding Menu
		initSlidingMenu(savedInstanceState);
	}
	
	//0628
	@Override
	public void selectItem(int position,String title){
		
		//toggle();
		showContent();//hide the menu 
		TextView tv = (TextView)findViewById(R.id.show_submenu_content);
		tv.setText(title);
	}
	/**
	 * Initial Sliding Menu
	 */
	private void initSlidingMenu(Bundle savedInstanceState) {
		// 設置滑動菜單的視圖
		setBehindContentView(R.layout.menu_frame);
		getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new LeftBottomFragment()).commit();		
		// 實例化滑動菜單對象
		SlidingMenu sm = getSlidingMenu();
		// 設置滑動陰影的寬度
		sm.setShadowWidthRes(R.dimen.shadow_width);
		// 設置滑動陰影的圖像資源
		sm.setShadowDrawable(R.drawable.shadow);
		// 設置滑動菜單視圖的寬度
		sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		// 設置漸入漸出效果的值
		sm.setFadeDegree(0.35f);
		// 設置觸摸屏幕的模式
		sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);		
	}
}

(5)LeftBottomFragment.java

Key:在菜單Fragment中定義回調函數  將Fragment的信息傳遞到Activity

package com.pps.myrenren.activity;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.pps.myrenren.adapter.CommonOrMoreAdapter;
import com.pps.myrenren.adapter.SettingAdapter;
import com.pps.myrenren.model.ItemComOrMoreModel;
import com.pps.myrenren.model.ItemSettingModel;


public class LeftBottomFragment extends Fragment{
	private View mView;
	private Context mContext;
	
	
	private ListView listview_common;
	private ListView listview_more;
	private ListView listview_setting;

	private List<ItemComOrMoreModel> commonModels;  //常用列表的Item集合
	private List<ItemComOrMoreModel> moreModels;    //不少其它列表的item集合
	private List<ItemSettingModel> settingModels;   //設置列表的item集合
	
	private SLMenuListOnItemClickListener mCallbacks;//0628
	
	//Key:
	public void onAttach(Activity activity){  
        super.onAttach(activity);  
        //假設該Acitivity沒有實現Callbacks接口  
        if(!(activity instanceof SLMenuListOnItemClickListener)){  
            try {  
                throw new Exception("LeftBottomFragment所在的Activity" +  
                        "必須實現Callbacks接口");  
            } catch (Exception e) {  
                // TODO Auto-generated catch block  
                e.printStackTrace();  
            }  
        } 
        //定義回調函數的接口對象的實例化---
        //把該Activity當成Callbacks對象  
        mCallbacks = (SLMenuListOnItemClickListener) activity;  
    }  
	
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		if (null == mView) {
			mView = inflater.inflate(R.layout.fragment_left_bottom, container,
					false);
			initView();
			initValidata();
			bindData();
			initialClickListener();
			//
		}
		return mView;
	}
	/**
	 * 初始化界面元素
	 */
	private void initView() {
		//---mView.findViewById()  not .findViewById()
		listview_common = (ListView) mView.findViewById(R.id.listview_common);
		
		listview_more = (ListView) mView.findViewById(R.id.listview_more);
		listview_setting = (ListView) mView.findViewById(R.id.listview_setting);

	}
	/**
	 * 初始化變量
	 */
	private void initValidata() {
		mContext = mView.getContext();
		commonModels=new ArrayList<ItemComOrMoreModel>();
		moreModels=new ArrayList<ItemComOrMoreModel>();
		settingModels=new ArrayList<ItemSettingModel>();
		//1:進行構造常用列表中的數據,圖標,名稱,數量
		Integer[] common_icon_id = new Integer[] {
				R.drawable.v5_2_1_desktop_list_newsfeed,
				R.drawable.v5_2_1_desktop_list_message,
				R.drawable.v5_2_1_desktop_list_chat,
				R.drawable.v5_2_1_desktop_list_friends,
				R.drawable.v5_2_1_desktop_list_search,
				R.drawable.v5_9_3_desktop_list_barcode };
		String[] arrays_commom=mContext.getResources().getStringArray(R.array.arrays_commom);
		int[] common_number=new int[]{0,1,2,3,4,1};
		for(int i=0;i<common_icon_id.length;i++)
		{
			ItemComOrMoreModel commcon=new ItemComOrMoreModel(common_icon_id[i], arrays_commom[i], common_number[i]);
			commonModels.add(commcon);
		}
		
		//2:進行構造不少其它列表中的數據,圖標,名稱,數量
		Integer[] more_icon_id=new Integer[]
				{R.drawable.v5_2_1_desktop_list_location,R.drawable.v5_2_1_desktop_list_page,R.drawable.v5_2_0_desktop_list_hot,R.drawable.v5_2_1_desktop_list_apps_center};
		String[] arrays_more=mContext.getResources().getStringArray(R.array.arrays_more);
		int[] more_number=new int[]{0,0,0,0};
		for(int i=0;i<more_icon_id.length;i++)
		{
			ItemComOrMoreModel more=new ItemComOrMoreModel(more_icon_id[i],arrays_more[i],more_number[i]);
		    moreModels.add(more);
		}
		
		//3:進行構造設置列表中的數據,圖標,名稱
		Integer[] setting_icon_id=new Integer[]{R.drawable.v_5_8day_mode_unselected,R.drawable.v5_2_1_desktop_list_settings,R.drawable.v5_2_1_desktop_list_log_out};
		String[] arrays_setting=mContext.getResources().getStringArray(R.array.arrays_setting);
		for(int i=0;i<setting_icon_id.length;i++)
		{
			ItemSettingModel setting=new ItemSettingModel(setting_icon_id[i],arrays_setting[i]);
			settingModels.add(setting);
		}		
	}

	/**
	 * 綁定數據
	 */
	private void bindData() {
       //建立適配器並且進行綁定數據到listview中
		listview_common.setAdapter(new CommonOrMoreAdapter(mContext, commonModels));
		listview_more.setAdapter(new CommonOrMoreAdapter(mContext, moreModels));
		listview_setting.setAdapter(new SettingAdapter(mContext, settingModels));
	}
	
	//0628:點擊滑動菜單子選項的回調接口
	public interface SLMenuListOnItemClickListener{
    	
    	public void selectItem(int position,String title);
    }
	
	/*菜單選項單擊響應事件的監聽函數*/
	public void initialClickListener(){
		
		//
		listview_common.setOnItemClickListener(new OnItemClickListener(){
			@Override
			public void onItemClick(AdapterView<?

> parent, View view, int position, long id) { //激發mCallbacks的selectItem方法 mCallbacks.selectItem(position, commonModels.get(position).getName()); } }); listview_more.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?

> parent, View view, int position, long id) { mCallbacks.selectItem(position, moreModels.get(position).getName()); } }); listview_setting.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView<?

> parent, View view, int position, long id) { // TODO Auto-generated method stub mCallbacks.selectItem(position, settingModels.get(position).getName()); } }); } }

(6)其它文件  省略  
相關文章
相關標籤/搜索