Hi Guys, Maybe you all are expert in terms of using RecyclerView in android. This blog is simple example for using filter option with RecyclerView adapter. As for now you will instantiate RecyclerView and set the adapter to RecyclerView as following way. RecyclerView list = (RecyclerView) findViewById(R.id.list); list.setLayoutManager(new LinearLayoutManager(this)); list.setHasFixedSize(true); ArrayList<Number> numbers = new ArrayList<>(); String ONEs[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN"}; String TENs[] = {"ZERO", "TEN", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY", "HUNDRED"}; String HUNDREDS[] = {"ZERO", "HUNDRED", "TWO HUND...
Hi guys, you can use NavigationView on both side if you want side menu in both left and right side in Android as following.
Your drawer layout will be
And toolbar is added in
As well,
And your
I hope this post is useful to you. kindly share your feedback as comment here.
Thank You
Your drawer layout will be
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view2" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="end" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer1" /> </android.support.v4.widget.DrawerLayout>
And toolbar is added in
app_bar_main
. So your app_bar_main.xml
will be
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg" android:fitsSystemWindows="true" tools:context="com.guna.navigationviewonbothssides.MainActivity"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" app:elevation="0dp"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@android:color/transparent" app:popupTheme="@style/AppTheme.PopupOverlay"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageButton android:id="@+id/menuLeft" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:src="@drawable/ic_menu_white_24dp" android:tint="@color/colorPrimary" /> <ImageButton android:id="@+id/menuRight" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:src="@drawable/ic_menu_white_24dp" android:tint="@color/colorPrimary" /> </RelativeLayout> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_main" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" /> </android.support.design.widget.CoordinatorLayout>So as you see the above two xml,
nav_view
will be opened from left to right by taping menuLeft
As well,
nav_view2
will be opened from right to left by taping menuRight
And your
activity_main_drawer
and activity_main_drawer2
will have the Navigation items which will look like as following. <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkableBehavior="single"> <item android:id="@+id/nav_camera" android:icon="@drawable/ic_menu_camera" android:title="Camera" /> <item android:id="@+id/nav_gallery" android:icon="@drawable/ic_menu_gallery" android:title="Gallery" /> <item android:id="@+id/nav_slideshow" android:icon="@drawable/ic_menu_slideshow" android:title="Slideshow" /> <item android:id="@+id/nav_manage" android:icon="@drawable/ic_menu_manage" android:title="Tools" /> </group> <item android:title="Communicate"> <menu> <item android:id="@+id/nav_share" android:icon="@drawable/ic_menu_share" android:title="Share" /> <item android:id="@+id/nav_send" android:icon="@drawable/ic_menu_send" android:title="Send" /> </menu> </item> </menu>You can handle these
NavigationView
's in code as following.
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "You have chosen mail option", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ImageButton menuLeft = (ImageButton) findViewById(R.id.menuLeft); ImageButton menuRight = (ImageButton) findViewById(R.id.menuRight); menuLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { drawer.openDrawer(GravityCompat.START); } } }); menuRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (drawer.isDrawerOpen(GravityCompat.END)) { drawer.closeDrawer(GravityCompat.END); } else { drawer.openDrawer(GravityCompat.END); } } }); NavigationView navigationView1 = (NavigationView) findViewById(R.id.nav_view); NavigationView navigationView2 = (NavigationView) findViewById(R.id.nav_view2); navigationView1.setNavigationItemSelectedListener(this); navigationView2.setNavigationItemSelectedListener(this); } @Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else if (drawer.isDrawerOpen(GravityCompat.END)) { drawer.closeDrawer(GravityCompat.END); } else { super.onBackPressed(); } } @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; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); String text = ""; if (id == R.id.nav_camera) { text = "camera"; } else if (id == R.id.nav_gallery) { text = "gallery"; } else if (id == R.id.nav_slideshow) { text = "slideshow"; } else if (id == R.id.nav_manage) { text = "tools"; } else if (id == R.id.nav_share) { text = "share"; } else if (id == R.id.nav_send) { text = "send"; } else if (id == R.id.nav_home) { text = "home"; } else if (id == R.id.nav_bar) { text = "bar"; } else if (id == R.id.nav_pool) { text = "pool"; } Toast.makeText(this, "You have chosen " + text, Toast.LENGTH_LONG).show(); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.END); return true; } }
I hope this post is useful to you. kindly share your feedback as comment here.
NavigationView example in Android
Source code on GitHub
Thank You
ReplyDeleteThe blog is very informative.Keep posting like this.
Aviation academy in chennai
Great article with excellent idea i appreciate your post thankyou so much and let keep on sharing your stuffs
ReplyDeleteBest woocommerce development company
best web designig company in chennai
best google adwords campaign agencies in chennai
Local SEO services in Chennai
google adwords service in chennai
best google adwords campaign agencies in chennai
Branding companies in Chennai
Thanks adminim artık mynet sohbet odaları kategorisi içeriyor ,daha kaliteli sohbet ortamı için katılın. mynet sohbet
ReplyDeletecoin haber - koin haber - kripto para haberleri - coin haber - instagram video indir - instagram takipçi satın al - instagram takipçi satın al - tiktok takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - instagram takipçi satın al - binance güvenilir mi - binance güvenilir mi - binance güvenilir mi - binance güvenilir mi - instagram beğeni satın al - instagram beğeni satın al - google haritalara yer ekleme - btcturk güvenilir mi - binance hesap açma - kuşadası kiralık villa - tiktok izlenme satın al - instagram takipçi satın al - sms onay - paribu sahibi - binance sahibi - btcturk sahibi - paribu ne zaman kuruldu - binance ne zaman kuruldu - btcturk ne zaman kuruldu - youtube izlenme satın al - torrent oyun - google haritalara yer ekleme - altyapısız internet - bedava internet - no deposit bonus forex - erkek spor ayakkabı - tiktok jeton hilesi - tiktok beğeni satın al - microsoft word indir - misli indir - instagram takipçi satın al
ReplyDeleteTürkiye'nin en güvenilir takipçi satış platformu : takipçi satın al
ReplyDeleteİnstagram takipçi mi almak istiyorsun sadece tıkla : instagram takipçi satın al
Tiktokta fenomen olmaya hazır mısın işte seçenekler : tiktok takipçi satın al
2 . takipçi satın alma linki : takipçi satın al
3 . takipçi satın alma linki : takipçi satın al
ReplyDeleteGet inspired by your blog. Keep doing like this....
Android Training in Bangalore
Android Classes in Pune
Android Classes in Hyderabad
Android Training in Gurgaon
Android Training in Delhi
Hi thanks for sharinng this
ReplyDelete"First off I want to say excellent blog! I had a quick question in which I'd like
ReplyDeleteto ask if you don't mind. I was interested to know how you center yourself and clear your mind prior to writing.
I have had a tough time clearing my thoughts in getting my thoughts out there.
I do enjoy writing however it just seems like the f
First 10 to 15 minutes are generally wasted simply just trying to figure out how to begin. Any ideas or hints?
Thank you!"
야동
대딸방
외국인출장
마사지
바카라사이트
oncasino
ReplyDeletesmm panel
ReplyDeletesmm panel
iş ilanları
İnstagram takipçi satın al
https://www.hirdavatciburada.com
beyazesyateknikservisi.com.tr
servis
tiktok jeton hilesi
tuzla toshiba klima servisi
ReplyDeletekartal daikin klima servisi
ümraniye daikin klima servisi
beykoz toshiba klima servisi
üsküdar toshiba klima servisi
beykoz beko klima servisi
üsküdar beko klima servisi
kadıköy beko klima servisi
kartal lg klima servisi
Good content. You write beautiful things.
ReplyDeletevbet
hacklink
mrbahis
mrbahis
vbet
sportsbet
sportsbet
korsan taksi
taksi
kralbet
ReplyDeletebetpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
betmatik
L8FB
elf bar
ReplyDeletebinance hesap açma
sms onay
Z8R
elazığ
ReplyDeletekağıthane
kastamonu
nevşehir
niğde
yalova
J6Qİ0Z
salt likit
ReplyDeletesalt likit
M4P
artvin
ReplyDeletekastamonu
urfa
balıkesir
bitlis
DYM
resimli magnet
ReplyDeleteresimli magnet
çerkezköy çatı ustası
silivri çatı ustası
dijital kartvizit
BEGJ
antiseo.com.tr
ReplyDeletesex hattı
https://izmirkizlari.com
sms onay
XXZ
glassagram
ReplyDeleteallsmo
instagram gizli hesap görme
revelio
bestwhozi
3FMCX
صيانة افران جدة p0xJJLjVNc
ReplyDeleteشركة تنظيف فلل بجازان 8HIy3NauuP
ReplyDelete