简体   繁体   English

Android Studio导航抽屉-在导航右侧添加箭头图标

[英]Android studio navigation drawer - add arrow icon in the right of nav

please help me. 请帮我。

how can i add arrow icon in the right of my nav? 如何在导航栏右侧添加箭头图标?

example: 例:

Home > 主页>


CATEGORY > 类别>


MY ACCOUNT > 我的帐户>


here is my code. 这是我的代码。

JSONObject jsonObj = new JSONObject(CATEGORIESJSON);
categories = jsonObj.getJSONArray(CATEGORIES_RESULTS);

listDataHeader = new ArrayList<String>();
listDataChild = new HashMap<String, List<Category>>();

// Adding group data
listDataHeader.add("HOME");
listDataHeader.add("CATEGORY");
listDataHeader.add("MY ACCOUNT");
listDataHeader.add("REFER A FRIEND");
listDataHeader.add("ABOUT");
listDataHeader.add("PRIVACY POLICY");
listDataHeader.add("SHIPPING TERMS");
listDataHeader.add("SHOPPING GUIDE");
listDataHeader.add("CONTACT US");
if(customersid.matches("10865")){
    listDataHeader.add("LOGIN");
}else{
    listDataHeader.add("LOGOUT");
}

List<Category> CATEGORY = new ArrayList<Category>();
for(int i=0;i<categories.length();i++){
    JSONObject c = categories.getJSONObject(i);
    Category category = new Category();
    category.name = c.getString(CATEGORIES_NAME);
    category.id = c.getString(CATEGORIES_ID);
    category.image2 = c.getString(CATEGORIES_IMAGE2);

    CATEGORY.add(category);
}

listDataChild.put(listDataHeader.get(1), CATEGORY); // Header, Child data

here is my ExpandableListAdapter code 这是我的ExpandableListAdapter代码

package com.example.administrator.mosbeau;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;

import java.util.HashMap;
import java.util.List;


/**
 * Created by Administrator on 9/21/2015.
 */

@SuppressWarnings("deprecation")

public class ExpandableListAdapter extends BaseExpandableListAdapter {

    private Context _context;
    private List<String> _listDataHeader; // header titles
    // child data in format of header title, child title
    private HashMap<String, List<Category>> _listDataChild;

    public ExpandableListAdapter(Context context, List<String> listDataHeader,
                                 HashMap<String, List<Category>> listChildData) {
        this._context = context;
        this._listDataHeader = listDataHeader;
        this._listDataChild = listChildData;
    }

    @Override
    public Category getChild(int groupPosition, int childPosititon) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                .get(childPosititon);
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public View getChildView(int groupPosition, final int childPosition,
                             boolean isLastChild, View convertView, ViewGroup parent) {

        final Category childCategory = (Category) getChild(groupPosition, childPosition);

        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) this._context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.list_item, null);
        }

        TextView txtListChild = (TextView) convertView
                .findViewById(R.id.lblListItem);

        txtListChild.setText(childCategory.name);
        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                .size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return this._listDataHeader.get(groupPosition);
    }

    @Override
    public int getGroupCount() {
        return this._listDataHeader.size();
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
                             View convertView, ViewGroup parent) {
        String headerTitle = (String) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) this._context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = infalInflater.inflate(R.layout.list_group, null);
        }

        TextView lblListHeader = (TextView) convertView
                .findViewById(R.id.lblListHeader);
        lblListHeader.setTypeface(null, Typeface.BOLD);
        lblListHeader.setText(headerTitle);

        ExpandableListView mExpandableListView = (ExpandableListView) parent;
        mExpandableListView.expandGroup(1);

        return convertView;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
}

please help me. 请帮我。

thanks, 谢谢,

joe

have you know about using 'include' tag for your xml layout? 您是否知道在XML布局中使用“包含”标记?

i think i have some reference for you to doing this.. see this link , it have a good explaination 我想我对此有一些参考。.看到这个链接 ,它有很好的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android Eclipse的“导航抽屉活动模板”中使“图标”显示在“导航抽屉”的右侧和“ mTitle”的左侧? - How to make Icon appear to the right of Nav Drawer and left of mTitle in Navigation Drawer Activity Template in Android Eclipse? 默认的Android Studio导航抽屉活动模板不显示汉堡图标,仅显示箭头图标 - Default Android Studio Navigation Drawer Activity Template does not show Hamburger Icon, only arrow icon 将图标添加到导航抽屉Android - Add icon to navigation drawer Android Android 导航抽屉向右切换图标 - Android navigation drawer toggle icon to right 导航抽屉右下角图标android - navigation drawer bottom right icon android Android Studio导航抽屉图标颜色 - Android studio navigation drawer icon color 在Android Studio的默认导航抽屉中添加图标 - Adding icon in the default navigation drawer in Android Studio 如何在Android导航抽屉中更改标题箭头图标 - How to change the title arrow icon in android navigation drawer 右上角的导航抽屉图标显示汉堡图标的后退箭头图标 - Navigation Drawer icon on the top right is showing Back arrow icon insted of Hamburger icon 隐藏应用程序图标时,导航抽屉图标是一个箭头? - Nav Drawer icon is an arrow when hiding appicon?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM