我正在處理導航抽屜,我想在導航抽屜中顯示用戶的詳細信息,如個人資料,聯繫我們,註銷等,如果他沒有登錄,那麼我想只顯示一個項目這是已經在其上登錄閒來無事必須顯示在它,我將使用JSON用於身份驗證的登錄請參考圖片的朋友從導航抽屜1登錄
從導航抽屜1登錄
回答
你的問題很廣。但是,要達到您想要的效果,您可能需要使用MaterialDrawer庫。只需檢查他們的自述文件,它使用起來非常簡單。
「登錄」功能,您正在尋找將在你的抽屜AccountHeader
,例如:
// Create the AccountHeader
AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(R.drawable.header)
.addProfiles(
new ProfileDrawerItem().withName("Mike Penz").withEmail("[email protected]").withIcon(getResources().getDrawable(R.drawable.profile))
)
.withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
@Override
public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
return false;
}
})
.build();
//Now create your drawer and pass the AccountHeader.Result
new DrawerBuilder()
.withAccountHeader(headerResult)
//additional Drawer setup as shown above
...
.build();
(從官方README拍攝片段,再次:每一件事情是there)。
我也想通過使用JSONS來實現它 –
這將是一個完全獨立的問題,然後:http://developer.android.com/reference/android/util/JsonReader.html我鼓勵你編輯你的主要問題提供更多細節。 –
你的問題很廣,但如果你使用的是導航視圖中,可以使用由機器人提供
navigationView.inflateHeaderView(layoutResId);
navigationView.inflateMenu(menuResId);
導航視圖更改標題視圖和抽屜的項目。所以它不是第三方庫,集成起來很簡單。
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- your content layout -->
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
你可以在這裏找到完整的信息 - http://android-developers.blogspot.in/2015/05/android-design-support-library.html
http://developer.android.com/reference/android/support/design/widget/NavigationView.html
是的,我正在使用導航視圖 –
我的想法是if(islogged == true){navigationView.inflateHeaderView(layoutResId); navigationView.inflateMenu(menuResId); else {navigationView.inflateHeaderView(layoutResId); navigationView.inflateMenu(menuResId);} –
是的,當然,你必須檢查用戶是否已登錄 – Ishan
- 1. 登錄+導航抽屜
- 2. 從導航抽屜
- 3. 導航抽屜
- 4. 難度從導航抽屜
- 5. ActionbarSherlock導航抽屜
- 6. Android導航抽屜?
- 7. Android導航抽屜
- 8. 導航抽屜,ResourceNotFoundException
- 9. 導航抽屜與導航抽屜片段
- 10. Facebook登錄按鈕出現在導航抽屜中
- 11. 問題在登錄和導航抽屜之間onBackpress
- 12. 在導航抽屜中導航錯誤?
- 13. 帶導航抽屜的片段導航
- 14. 導航抽屜重疊CollapsingToolbar
- 15. AndroidSlidingUpPanel與抽屜式導航
- 16. 片段導航抽屜
- 17. 添加導航抽屜AppCompatActivity
- 18. 用NativeScript導航抽屜
- 19. 導航抽屜定製
- 20. RelativeLayout導航抽屜裏面
- 21. 導航抽屜不顯示
- 22. Android - 導航抽屜碎片
- 23. 導航抽屜不工作
- 24. Android碎片導航抽屜
- 25. 處理導航抽屜
- 26. 錯誤抽屜式導航
- 27. 錯誤導航抽屜
- 28. Gmail導航抽屜效果
- 29. 更改導航抽屜
- 30. 導航抽屜和MapFragment
投票決定關閉,因爲這個問題太寬泛。 – Skynet