()

2017-05-01 7 views
0

안녕하세요 저는 ProfileSettingDrawerItem을 클릭하면 작업을 열 필요가 있지만,이 DrawerBuilder()AccountHeaderBuilder()하지에 정의되어 있습니다.()

headerResult = new AccountHeaderBuilder() 
    .withActivity(this) 
    .withCompactStyle(true) 
    .withHeaderBackground(R.drawable.header) 
    .addProfiles(
     profile, 
     profile2, 
     //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account) 
     item = new ProfileSettingDrawerItem().withName("Add Account").withDescription("Add Account").withIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus).actionBar().paddingDp(5).colorRes(R.color.material_drawer_dark_primary_text)).withIdentifier(PROFILE_SETTING), 
     item1= new ProfileSettingDrawerItem().withName("Manage Account").withIcon(GoogleMaterial.Icon.gmd_settings).withIdentifier(11) 
    ) 
    .withSavedInstance(savedInstanceState) 
    .build(); 

//Create the drawer 
result = new DrawerBuilder() 
    .withActivity(this) 
    .withToolbar(toolbar) 
    .withHasStableIds(true) 
    .withDrawerLayout(R.layout.crossfade_drawer) 
    .withDrawerWidthDp(72) 
    .withGenerateMiniDrawer(true) 
    .withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header 
    .addDrawerItems(
     new PrimaryDrawerItem().withName("NASLOVNA").withIcon(GoogleMaterial.Icon.gmd_sun).withIdentifier(1), 
     new PrimaryDrawerItem().withName("MODA").withIcon(FontAwesome.Icon.faw_home).withBadge("22").withBadgeStyle(new BadgeStyle(Color.RED, Color.RED)).withIdentifier(2).withSelectable(false), 
     new PrimaryDrawerItem().withName("LIFESTYLE").withIcon(FontAwesome.Icon.faw_gamepad).withIdentifier(3), 
     new PrimaryDrawerItem().withName("LEPOTA I ZDRAVLJE").withIcon(GoogleMaterial.Icon.gmd_sun).withIdentifier(8), 
     new PrimaryDrawerItem().withName("VODIC").withIcon(FontAwesome.Icon.faw_eye).withIdentifier(4), 
     new PrimaryDrawerItem().withName("MAMA I DETE ").withIcon(GoogleMaterial.Icon.gmd_adb).withIdentifier(5), 
     new PrimaryDrawerItem().withName("INTERVJU").withIcon(GoogleMaterial.Icon.gmd_sun).withIdentifier(6), 
     new PrimaryDrawerItem().withName("BLOG").withIcon(GoogleMaterial.Icon.gmd_sun).withIdentifier(7), 
     new SectionDrawerItem().withName(R.string.drawer_item_section_header), 
     new SecondaryDrawerItem().withName("SETTINGS").withIcon(FontAwesome.Icon.faw_github), 
     new SecondaryDrawerItem().withName("Contact").withIcon(GoogleMaterial.Icon.gmd_format_color_fill).withTag("Bullhorn") 
    ) // add the items we want to use with our Drawer 
    .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { 
     @Override 
     public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { 
      // if (drawerItem instanceof Nameable) { 
      Toast.makeText(CrossfadeDrawerLayoutActvitiy.this, ((Nameable) drawerItem).getName().getText(CrossfadeDrawerLayoutActvitiy.this), Toast.LENGTH_SHORT).show(); 
      if (drawerItem != null) { 
       Intent intent = null; 
       if (drawerItem.getIdentifier() == 1) { 
        intent = new Intent(CrossfadeDrawerLayoutActvitiy.this, AddAccount.class); 
       } else if (drawerItem.getIdentifier() == 11) { 
        intent = new Intent(CrossfadeDrawerLayoutActvitiy.this, AddAccount.class); 
       } 
       if (intent != null) { 
        CrossfadeDrawerLayoutActvitiy.this.startActivity(intent); 
       } 
      } 
      //we do not consume the event and want the Drawer to continue with the event chain 
      return false; 
     } 
    }) 
    .withSavedInstance(savedInstanceState) 
    .withShowDrawerOnFirstLaunch(true) 
    .build(); 

AddAccount.class를 엽니 다 item1 = new ProfileSettingDrawerItem().withName("Manage Account").withIcon(GoogleMaterial.Icon.gmd_settings).withIdentifier(11)을 누른 후 어떤 방법이 있나요 : 여기 코드인가?

답변

0

클릭 이벤트에 대해 OnAccountHeaderListener 및 수신기를 정의 할 수 있습니다.

.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { 
    @Override 
    public boolean onProfileChanged(View view, IProfile profile, boolean current) { 
     //catch the event here and launch your activity 
     //false if you have not consumed the event and it should close the drawer 
     return false; 
    } 
})