developer.android.com μΉ μ¬μ΄νΈ μ μμ΅μμ νμλ κ²μ²λΌ μλνλ νμ λλ‘μ΄λ₯Ό μμ±νμ΅λλ€ . κ·Έλ¬λ μ΄μ λ΄ μμ© νλ‘κ·Έλ¨μ μ¬λ¬ νλμ μν΄ NavigationDrawer.classμμ λ§λ νλμ Navigation Drawerλ₯Ό μ¬μ©νκ³ μΆμ΅λλ€.
λ΄ μ§λ¬Έμ, μ¬κΈ° λκ΅°κ°κ° μμ νν 리μΌμ λ§λ€ μ μλ€λ©΄, μ¬λ¬ νλμ νλμ νμ μλμ μ¬μ©νλ λ°©λ²μ μ€λͺ ν©λλ€.
μ¬λ¬ νλμ λν μ΄ Answer Android Navigation Drawerμμ μ²μ μ½μμ΅λλ€.
νμ§λ§ λ΄ νλ‘μ νΈμμ μλνμ§ μμμ΅λλ€.
public class NavigationDrawer extends Activity {
public DrawerLayout drawerLayout;
public ListView drawerList;
private ActionBarDrawerToggle drawerToggle;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle((Activity) this, drawerLayout, R.drawable.ic_drawer, 0, 0) {
public void onDrawerClosed(View view) {
getActionBar().setTitle(R.string.app_name);
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(R.string.menu);
}
};
drawerLayout.setDrawerListener(drawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
layers = getResources().getStringArray(R.array.layers_array);
drawerList = (ListView) findViewById(R.id.left_drawer);
View header = getLayoutInflater().inflate(R.layout.drawer_list_header, null);
drawerList.addHeaderView(header, null, false);
drawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, android.R.id.text1,
layers));
View footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.drawer_list_footer, null, false);
drawerList.addFooterView(footerView);
drawerList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
map.drawerClickEvent(pos);
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (drawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
drawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig);
}
}
μ΄ νλμμ λλ νμ μλμ κ°κ³ μΆμ΄μ βNavigationDrawerβλ₯Ό νμ₯νκ³ λ€λ₯Έ νλμμλ λμΌν νμ μλμ μ¬μ©νλ €κ³ ν©λλ€.
public class SampleActivity extends NavigationDrawer {...}
무μμ λ°κΏμΌν μ§ λͺ¨λ₯΄κ² μ΅λλ€ β¦
λ΅λ³
νμ λλ‘μ΄λ₯Ό μνλ©΄ μ‘°κ°μ μ¬μ©ν΄μΌν©λλ€. μ§λμ£Όμμ΄ νν 리μΌμ λ°λμΌλ©° νλ₯νκ² μλν©λλ€.
http://developer.android.com/training/implementing-navigation/nav-drawer.html
μ΄ νν 리μΌμμ μν μ½λλ₯Ό λ€μ΄λ‘λνμ¬μ΄λ₯Ό μννλ λ°©λ²μ νμΈν μλ μμ΅λλ€.
ννΈμμ΄ :
μ΄κ²μ BaseActivity μ½λμ λλ€.
public class BaseActivity extends Activity
{
public DrawerLayout drawerLayout;
public ListView drawerList;
public String[] layers;
private ActionBarDrawerToggle drawerToggle;
private Map map;
protected void onCreate(Bundle savedInstanceState)
{
// R.id.drawer_layout should be in every activity with exactly the same id.
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle((Activity) this, drawerLayout, R.drawable.ic_drawer, 0, 0)
{
public void onDrawerClosed(View view)
{
getActionBar().setTitle(R.string.app_name);
}
public void onDrawerOpened(View drawerView)
{
getActionBar().setTitle(R.string.menu);
}
};
drawerLayout.setDrawerListener(drawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
layers = getResources().getStringArray(R.array.layers_array);
drawerList = (ListView) findViewById(R.id.left_drawer);
View header = getLayoutInflater().inflate(R.layout.drawer_list_header, null);
drawerList.addHeaderView(header, null, false);
drawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, android.R.id.text1,
layers));
View footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.drawer_list_footer, null, false);
drawerList.addFooterView(footerView);
drawerList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
map.drawerClickEvent(pos);
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (drawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
drawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig);
}
}
νμ λλ‘μ΄κ° νμν λ€λ₯Έ λͺ¨λ νλμ νλ μ체 λμ μ΄ νλμ νμ₯ν΄μΌν©λλ€. μ :
public class AnyActivity extends BaseActivity
{
//Because this activity extends BaseActivity it automatically has the navigation drawer
//You can just write your normal Activity code and you don't need to add anything for the navigation drawer
}
XML
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- Put what you want as your normal screen in here, you can also choose for a linear layout or any other layout, whatever you prefer -->
</FrameLayout>
<!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
νΈμ§νλ€:
λλ μ½κ°μ μ΄λ €μμ κ²ͺμμΌλ―λ‘ NullPointerExceptionsλ₯Ό μ»λλ€λ©΄ μ¬κΈ°μ ν΄κ²°μ±
μ΄ μμ΅λλ€. BaseActivityμμ onCreate ν¨μλ₯Όλ‘ λ³κ²½νμμμ€ protected void onCreateDrawer(). λλ¨Έμ§λ λμΌνκ² μ μ§ λ μ μμ΅λλ€. BaseActivityλ₯Ό νμ₯νλ νλμμ μ½λλ₯Ό λ€μ μμλ‘ λ£μΌμμμ€.
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
super.onCreateDrawer();
μ΄κ²μ λ΄ λ¬Έμ λ₯Ό ν΄κ²°νλ λ° λμμ΄λμμ΅λλ€. λμμ΄λκΈ°λ₯Ό λ°λλλ€.
μ§λ¬Έμ΄ μμΌμλ©΄ μ¬λ¬ νλμ΄ ν¬ν¨ λ νμ μ°½μ λ§λλ λ°©λ²μ λλ€.
νΈμ§ 2 :
@GregDanμ΄ λ§νλ―μ΄ onCreateDrawerλ₯Ό BaseActivityμ¬μ μ setContentView()νκ³ νΈμΆ ν μ μμ΅λλ€ .
@Override
public void setContentView(@LayoutRes int layoutResID)
{
super.setContentView(layoutResID);
onCreateDrawer() ;
}
λ΅λ³
μ΅κ³ μ ꡬνμ μ°Ύμμ΅λλ€. κ·Έκ²μμμμ κ΅¬κΈ I / O 2014 μμ© νλ‘κ·Έλ¨.
κ·Έλ€μ Kevinκ³Ό κ°μ μ κ·Όλ²μ μ¬μ©ν©λλ€. I / O μ±μ λΆνμν λͺ¨λ νλͺ©μμ μμ μ μΆμν ν μ μλ€λ©΄ νμν λͺ¨λ κ²μ μΆμΆ ν μ μμΌλ©° Googleμ νμ λλ‘μ΄ ν¨ν΄μ μ¬λ°λ₯Έ μ¬μ©λ²μ 보μ₯ν©λλ€. κ° νλμλ μ νμ DrawerLayoutμΌλ‘ κΈ°λ³Έ λ μ΄μμμ΄ μμ΅λλ€. ν₯λ―Έλ‘μ΄ λΆλΆμ λ€λ₯Έ νλ©΄μΌλ‘ μ΄λνλ λ°©λ²μ
λλ€. λ€μ BaseActivityκ³Ό κ°μ΄ ꡬνλ©λλ€ .
private void goToNavDrawerItem(int item) {
Intent intent;
switch (item) {
case NAVDRAWER_ITEM_MY_SCHEDULE:
intent = new Intent(this, MyScheduleActivity.class);
startActivity(intent);
finish();
break;
μ΄κ²μ νμ¬ μ‘°κ°μ μ‘°κ° νΈλμμ μΌλ‘ λ체νλ μΌλ°μ μΈ λ°©λ²κ³Ό λ€λ¦ λλ€. κ·Έλ¬λ μ¬μ©μλ μκ°μ μ°¨μ΄λ₯Ό λ°κ²¬νμ§ λͺ»ν©λλ€.
λ΅λ³
λ°λΌμμ΄ λ΅λ³μ λͺ λ λ¦μμ§λ§ λκ΅°κ°λ κ·Έκ²μ κ°μ¬ ν κ²μ λλ€. Androidλ μ¬λ¬ νλμ΄ ν¬ν¨ λ νλμ νμ μ°½μλ³΄λ€ μ½κ² ββμ¬μ©ν μμλ μλ‘μ΄ μμ ―μ μ 곡νμ΅λλ€.
android.support.design.widget.NavigationViewλ λͺ¨λ μμ΄λ©° λ©λ΄ ν΄λμ μ체 λ μ΄μμμ΄ μμ΅λλ€. μ¬μ©νλ λ°©λ²μ λ€μκ³Ό κ°μ λ°©μμΌλ‘ xml λ μ΄μμμ λννλ κ²μ λλ€.
-
λ£¨νΈ λ μ΄μμμ
<include ... />λ©νλλ λ μ΄μμ (2 μ°Έμ‘°)κ³Ό android.support.design.widget.NavigationViewμ λ μμμ ν¬ν¨ νλ android.support.v4.widget.DrawerLayoutμ λλ€.<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" />
nav_header_mainμ Navigation Drawarμ ν€λμ λ°©ν₯ = μμ§ μΈ LinearLayoutμ λλ€.
activity_main_drawerλ res / menu λλ ν 리μ λ©λ΄ xmlμ λλ€. μ νν νλͺ©κ³Ό κ·Έλ£Ήμ ν¬ν¨ ν μ μμ΅λλ€. AndroidStudio Galleryλ₯Ό μ¬μ©νλ κ²½μ° λ§λ²μ¬κ° κΈ°λ³Έ λ§λ²μ¬λ₯Ό λ§λ€κ³ μ΅μ μ΄ λ¬΄μμΈμ§ νμΈν μ μμ΅λλ€.
-
μ± λ° λ μ΄μμμ μΌλ°μ μΌλ‘ android.support.design.widget.CoordinatorLayoutμ΄λ©° μ¬κΈ°μλ android.support.design.widget.AppBarLayout (android.support.v7.widget.Toolbar ν¬ν¨) λ°
<include ... >for. μ€μ λ΄μ© (3 μ°Έμ‘°)<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" tools:context="yourpackage.MainActivity"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_main" /> -
μ½ν μΈ λ μ΄μμμ μνλ λ μ΄μμμ΄ λ μ μμ΅λλ€. μ΄κ²μ νλμ μ£Όμ λ΄μ©μ ν¬ν¨νλ λ μ΄μμμ λλ€ (νμ μλμ΄λ μ± λ°λ ν¬ν¨λμ§ μμ).
μ΄μ μ΄ λͺ¨λ κ²μ λ©μ§ μ μμ΄ λ λ μ΄μμμΌλ‘ κ° νλμ λν ν μ μμ§λ§ NavigationView (1 λ¨κ³ μ°Έμ‘°)κ° νμ activity_main_drawer (λλ 무μμ΄λ )λ₯Ό κ°λ¦¬ ν€λλ‘νλ€λ κ²μ λλ€. μ¦, λͺ¨λ νλμ λν΄ λμΌν (*) νμ μ°½μ κ°κ²λ©λλ€.
- κ·Έκ²λ€μ NavigationView μ λμΌν μΈμ€ν΄μ€ λ μλμ§λ§ 곡μ νκ² λ§νλ©΄ μμμ μ€λͺ ν BaseActivity μ루μ μΌλ‘λ λΆκ°λ₯νμ΅λλ€.
λ΅λ³
νλ κ·Έλ£Ήκ°μ κ³΅ν΅ νμ λλ‘μ΄λ₯Ό μ¬μ¬μ©νλ κ°μ₯ μ¬μ΄ λ°©λ²
app_base_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:id="@+id/view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/menu_test"
/>
</android.support.v4.widget.DrawerLayout>
AppBaseActivity.java
/*
* This is a simple and easy approach to reuse the same
* navigation drawer on your other activities. Just create
* a base layout that conains a DrawerLayout, the
* navigation drawer and a FrameLayout to hold your
* content view. All you have to do is to extend your
* activities from this class to set that navigation
* drawer. Happy hacking :)
* P.S: You don't need to declare this Activity in the
* AndroidManifest.xml. This is just a base class.
*/
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
public abstract class AppBaseActivity extends AppCompatActivity implements MenuItem.OnMenuItemClickListener {
private FrameLayout view_stub; //This is the framelayout to keep your content view
private NavigationView navigation_view; // The new navigation view from Android Design Library. Can inflate menu resources. Easy
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
private Menu drawerMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.app_base_layout);// The base layout that contains your navigation drawer.
view_stub = (FrameLayout) findViewById(R.id.view_stub);
navigation_view = (NavigationView) findViewById(R.id.navigation_view);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 0, 0);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
drawerMenu = navigation_view.getMenu();
for(int i = 0; i < drawerMenu.size(); i++) {
drawerMenu.getItem(i).setOnMenuItemClickListener(this);
}
// and so on...
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
/* Override all setContentView methods to put the content view to the FrameLayout view_stub
* so that, we can make other activity implementations looks like normal activity subclasses.
*/
@Override
public void setContentView(int layoutResID) {
if (view_stub != null) {
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
View stubView = inflater.inflate(layoutResID, view_stub, false);
view_stub.addView(stubView, lp);
}
}
@Override
public void setContentView(View view) {
if (view_stub != null) {
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
view_stub.addView(view, lp);
}
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
if (view_stub != null) {
view_stub.addView(view, params);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Pass the event to ActionBarDrawerToggle, if it returns
// true, then it has handled the app icon touch event
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle your other action bar items...
return super.onOptionsItemSelected(item);
}
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.item1:
// handle it
break;
case R.id.item2:
// do whatever
break;
// and so on...
}
return false;
}
}
λ΅λ³
μλ ν¬μ€ν°κ° μꡬνλ κ²μ μννλ €λ λ€λ₯Έ μ¬λμ Kevinμ΄ λ§ν λ°©μ λμ μ‘°κ°μ μ¬μ©νλ κ²μ΄ μ’μ΅λλ€. μ΄λ₯Ό μννλ λ°©λ²μ λν νλ₯ν μμ΅μλ λ€μκ³Ό κ°μ΅λλ€.
https://github.com/codepath/android_guides/wiki/Fragment-Navigation-Drawer
νλκ·Έλ¨ΌνΈ λμ μ‘ν°λΉν°λ₯Ό μ¬μ©νλλ‘ μ ννλ©΄ μ μ‘ν°λΉν°λ‘ μ΄λν λλ§λ€ νμ λλ‘μ΄κ° λ€μ μμ±λλ λ¬Έμ κ° λ°μν©λλ€. μ΄λ‘ μΈν΄ λ§€λ² νμ μλμ΄λ³΄κΈ° ννκ³ λλ¦¬κ² λ λλ§λ©λλ€.
λ΅λ³
λ΄ μ μμ : νλμ μ ν μ¬μ©νμ§ λ§κ³ μ‘°κ°μ μ¬μ©νκ³ μ²« λ²μ§Έ μ‘°κ°μ νμνλ 컨ν μ΄λ (μ : μ ν λ μ΄μμ)μμ κ΅μ²΄νμμμ€.
μ½λλ Android Developer Tutorialsμμ μ¬μ©ν μ μμ΅λλ€. μ¬μ©μ μ μνλ©΄λ©λλ€.
http://developer.android.com/training/implementing-navigation/nav-drawer.html
μ ν리μΌμ΄μ μμ μ μ λ λ§μ νλκ·Έλ¨ΌνΈλ₯Ό μ¬μ©ν΄μΌνλ©° μΈλΆ μ ν리μΌμ΄μ κ³Ό λ³λλ‘ AndroidManifest.xmlμμ μΈκΈ ν λ€ κ°μ§ κΈ°λ³Έ νλ λ§ μ ν리μΌμ΄μ μ κ΅νλμ΄μΌν©λλ€ (FacebookActivity).
-
SplashActivity : μ‘°κ°μ μ¬μ©νμ§ μκ³ FullScreen ν λ§λ₯Ό μ¬μ©ν©λλ€.
-
LoginSignUpActivity : NavigationDrawerλ₯Ό μ ν νμλ‘νμ§ μκ³ λ€λ‘ λ¨μΆλ νμνμ§ μμΌλ―λ‘ μΌλ° λꡬ λͺ¨μμ μ¬μ©νκΈ° λ§νλ©΄ μ΅μν 3 κ° λλ 4 κ°μ μ‘°κ°μ΄ νμν©λλ€. μ‘μ λ°μλ ν λ§ μ¬μ©
-
HomeActivity λλ DashBoard Activity : μ‘μ λ° μμ ν λ§λ₯Ό μ¬μ©ν©λλ€. μ¬κΈ°μλ νμ λλ‘μ΄κ° νμνλ©°, κ·Έ λ€μμ λμ€λ λͺ¨λ νλ©΄μ 곡μ λλ‘μ΄μ ν¨κ» 리ν보기κΉμ§ νλκ·Έλ¨ΌνΈ λλ μ€μ²© λ νλκ·Έλ¨ΌνΈμ λλ€. μ΄ μ‘ν°λΉν°μμλ λͺ¨λ μ€μ , μ¬μ©μ νλ‘ν λ±μ΄ μ‘°κ°μΌλ‘ νμλ©λλ€. μ¬κΈ°μ μ‘°κ°μ λ°± μ€νμ μΆκ°λμ§ μμΌλ©° μλ λ©λ΄ νλͺ©μμ μ΄λ¦½λλ€. μλ λμ λ€λ‘ λ²νΌμ΄ νμν μ‘°κ°μ κ²½μ° μλμ λ€ λ²μ§Έ μ’ λ₯μ νλμ΄ μμ΅λλ€.
-
μλμ΄μλ νλ. μ΄ μ‘ν°λΉν°μλ μλ¨μ λ€λ‘ λ²νΌμ΄ μμΌλ©° λ΄λΆ μ‘°κ°μ λμΌν μμ νμ μ€μ 곡μ ν©λλ€. νμ λ΄μμ΄ μμΌλ―λ‘ μ΄λ¬ν μ‘°κ°μ λ°± μ€νμ μΆκ°λ©λλ€.
[μΆκ° μ§μΉ¨μ https://stackoverflow.com/a/51100507/787399 μ°Έμ‘° ]
ν볡ν μ½λ©!
λ΅λ³
κΈ°λ³Έ νλμμμ΄ μ½λλ₯Ό μ λ°μ΄νΈνμμμ€. κ·Έλ¦¬κ³ νλ XMLμ drawer_list_headerλ₯Ό ν¬ν¨μν€λ κ²μ μμ§ λ§μμμ€.
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.drawer_list_header);
νλμ request ()λ₯Ό μ¬μ©νμ§ λ§μμμ€. κ·Έλ¬λ μ¬μ ν μ΄λ―Έμ§λ₯Ό ν΄λ¦νλ©΄ μλμ΄ λ³΄μ΄μ§ μμ΅λλ€. λλκ·Ένλ©΄ λͺ©λ‘ νλͺ©μ΄ μμ΄λ μλμ΄ λ³΄μ λλ€. λλ λ§μ΄ μλνμ§λ§ μ±κ³΅νμ§ λͺ»νμ΅λλ€. μ΄λ₯Ό μν΄ μ΄λμ΄ νμν©λλ€ β¦