Android nDrawer
生活随笔
收集整理的這篇文章主要介紹了
Android nDrawer
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
GitHub上一款流行的側滑,附上自己as編譯過的源碼?http://download.csdn.net/detail/lj419855402/8559039、
留個紀念,說不定以后用得到。
依賴一個lib?
/** Copyright 2015 Rudson Lima** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/ package br.liveo.ndrawer; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.util.SparseIntArray; import android.view.Menu; import android.view.View; import android.widget.Toast;import java.util.ArrayList; import java.util.List;import br.liveo.interfaces.NavigationLiveoListener; import br.liveo.navigationliveo.NavigationLiveo;public class MainActivity extends NavigationLiveo implements NavigationLiveoListener {public List<String> mListNameItem;@Overridepublic void onUserInformation() {//User information herethis.mUserName.setText("Rudson Lima");this.mUserEmail.setText("rudsonlive@gmail.com");this.mUserPhoto.setImageResource(R.drawable.lin);this.mUserBackground.setImageResource(R.drawable.ic_user_background);}@Overridepublic void onInt(Bundle savedInstanceState) {//Creation of the list items is here// set listener {required}this.setNavigationListener(this);// name of the list itemsmListNameItem = new ArrayList<>();mListNameItem.add(0, getString(R.string.inbox));mListNameItem.add(1, getString(R.string.starred));mListNameItem.add(2, getString(R.string.sent_mail));mListNameItem.add(3, getString(R.string.drafts));mListNameItem.add(4, getString(R.string.more_markers)); //This item will be a subHeadermListNameItem.add(5, getString(R.string.trash));mListNameItem.add(6, getString(R.string.spam));// icons list itemsList<Integer> mListIconItem = new ArrayList<>();mListIconItem.add(0, R.drawable.ic_inbox_black_24dp);mListIconItem.add(1, 0); //Item no icon set 0mListIconItem.add(2, 0); //Item no icon set 0mListIconItem.add(3, R.drawable.ic_drafts_black_24dp);mListIconItem.add(4, 0); //When the item is a subHeader the value of the icon 0mListIconItem.add(5, R.drawable.ic_delete_black_24dp);mListIconItem.add(6, R.drawable.ic_report_black_24dp);//{optional} - Among the names there is some subheader, you must indicate it hereList<Integer> mListHeaderItem = new ArrayList<>();mListHeaderItem.add(4);//{optional} - Among the names there is any item counter, you must indicate it (position) and the value hereSparseIntArray mSparseCounterItem = new SparseIntArray(); //indicate all items that have a countermSparseCounterItem.put(0, 7);mSparseCounterItem.put(6, 250);//If not please use the FooterDrawer use the setFooterVisible(boolean visible) method with value falsethis.setFooterInformationDrawer(R.string.settings, R.drawable.ic_settings_black_24dp);this.setNavigationAdapter(mListNameItem, mListIconItem, mListHeaderItem, mSparseCounterItem);}@Overridepublic void onItemClickNavigation(int position, int layoutContainerId) {FragmentManager mFragmentManager = getSupportFragmentManager();Fragment mFragment = new FragmentMain().newInstance(mListNameItem.get(position));if (mFragment != null){mFragmentManager.beginTransaction().replace(layoutContainerId, mFragment).commit();}}@Overridepublic void onPrepareOptionsMenuNavigation(Menu menu, int position, boolean visible) {//hide the menu when the navigation is opensswitch (position) {case 0:menu.findItem(R.id.menu_add).setVisible(!visible);menu.findItem(R.id.menu_search).setVisible(!visible);break;case 1:menu.findItem(R.id.menu_add).setVisible(!visible);menu.findItem(R.id.menu_search).setVisible(!visible);break;}}@Overridepublic void onClickUserPhotoNavigation(View v) {//user photo onClickToast.makeText(this, R.string.open_user_profile, Toast.LENGTH_SHORT).show();}@Overridepublic void onClickFooterItemNavigation(View v) {//footer onClickstartActivity(new Intent(this, SettingsActivity.class));} }
?
?
?
效果,效果圖
轉載于:https://www.cnblogs.com/LIANQQ/p/4388447.html
總結
以上是生活随笔為你收集整理的Android nDrawer的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#读取Excel显示到repeater
- 下一篇: FastDFS安装、配置、部署(三)-S