天天看點

android 中DrawerLayout實作抽屜,深度解讀Netty

super.onDrawerClosed(drawerView);

			actionBar.setTitle("主界面");

		}

		@Override

				public void onDrawerOpened(View drawerView) {

					super.onDrawerOpened(drawerView);

					actionBar.setTitle("菜單界面");

				}

		

	};

	//打開或者關閉時的狀态

	toggle.syncState();

	layout.setDrawerListener(toggle);

	

	

	



	for (int i = 0; i < string.length; i++) {

		list.add("想發火" + i);

	}

	

	

	if (list != null && list.size() > 0) {

		MyAdapter adapter = new MyAdapter(MainActivity.this, list);



		listView.setAdapter(adapter);

	}



	listView.setOnItemClickListener(new OnItemClickListener() {



		@Override

		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,

				long arg3) {

			Toast.makeText(MainActivity.this, "我想打死你,***",

					Toast.LENGTH_SHORT).show();

		}

	});

}



@Override

public boolean onOptionsItemSelected(MenuItem item) {

	return toggle.onOptionsItemSelected(item)||super.onOptionsItemSelected(item);

}

@Override

public void onConfigurationChanged(Configuration newConfig) {

	super.onConfigurationChanged(newConfig);

	toggle.onConfigurationChanged(newConfig);

}
           

}

class MyAdapter extends BaseAdapter {

private Context context;

private ArrayList<String> list;



public MyAdapter(Context context, ArrayList<String> list) {

	this.context = context;

	this.list = list;

}



@Override

public int getCount() {

	return list.size();

}



@Override

public Object getItem(int arg0) {

	return null;

}



@Override

public long getItemId(int arg0) {

	return arg0;

}



@Override

public View getView(int arg0, View arg1, ViewGroup arg2) {

	ViewHolder vHolder;

	if (arg1 == null) {

		arg1 = LayoutInflater.from(context).inflate(R.layout.listview_item,

				null);

		vHolder = new ViewHolder();

		vHolder.textView = (TextView) arg1.findViewById(R.id.list_text);

		arg1.setTag(vHolder);

	} else {

		vHolder = (ViewHolder) arg1.getTag();

	}

	String string = list.get(arg0);

	vHolder.textView.setText(string);

	return arg1;

}



class ViewHolder {

	TextView textView;

}
           

}

下面給出相關的布局檔案:



           

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.DrawerLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/drawer"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >



<LinearLayout

    android:layout_width="match_parent"

    android:layout_height="match_parent" >



    <ImageView

        android:id="@+id/img"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/ic_launcher" />
           

最後

一線網際網路Android面試題含詳解(初級到進階專題)

這些題目是今年群友去騰訊、百度、小米、樂視、美團、58、獵豹、360、新浪、搜狐等一線網際網路公司面試被問到的題目。并且大多數都整理了答案,熟悉這些知識點會大大增加通過前兩輪技術面試的幾率
android 中DrawerLayout實作抽屜,深度解讀Netty
**[CodeChina開源項目:《Android學習筆記總結+移動架構視訊+大廠面試真題+項目實戰源碼》](

)**

如果設定門檻,很多開發者朋友會是以錯過這套進階架構資料,錯過提升成為架構師的可能。這就失去了我們的初衷;讓更多人都能通過高效高品質的學習,提升自己的技術和格局,升職加薪。

最後送給大家一句話,望共勉,永遠不要放棄自己的夢想和追求;

本文已被騰訊CODING開源托管項目:《Android學習筆記總結+移動架構視訊+大廠面試真題+項目實戰源碼》收錄,自學資源及系列文章持續更新中…

如果設定門檻,很多開發者朋友會是以錯過這套進階架構資料,錯過提升成為架構師的可能。這就失去了我們的初衷;讓更多人都能通過高效高品質的學習,提升自己的技術和格局,升職加薪。

最後送給大家一句話,望共勉,永遠不要放棄自己的夢想和追求;

本文已被騰訊CODING開源托管項目:《Android學習筆記總結+移動架構視訊+大廠面試真題+項目實戰源碼》收錄,自學資源及系列文章持續更新中…