如何扩大导航列表中的动作栏? [英] How to expand navigation list in action bar?

查看:121
本文介绍了如何扩大导航列表中的动作栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的,你可以通过传递微调适配器和OnNavigationListener设置一个导航列表中的动作吧。问题是,在导航列表不填​​充大部分动作吧,如何使它扩大,如Gmail应用程序: 的Gmail应用实例:

我的应用程序:

和这里的code:

  // ...设置阵列适配器
动作条动作条= getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
NavigationListener navigationListener =新NavigationListener();
ListAdapter listAdapter =新ListAdapter();
actionBar.setListNavigationCallbacks(listAdapter,navigationListener);
actionBar.setDisplayShowTitleEnabled(假);
 

其他的问题,我面对的是微调项目的大小,他们表现出了非常小的,是因为我不通过定制的TextView(看截图)?比如我做什么:

 私有类ListAdapter扩展了BaseAdapter实现SpinnerAdapter {

    公共查看getView(INT POS,视图中查看,ViewGroup中的ViewGroup){
        TextView的文本=新的TextView(上下文);
        text.setText(arrayAdapter.getItem(POS)的ToString());
        返回文本;
    }

}
 

解决方案

您要实现的<一个href="http://developer.android.com/reference/android/widget/SpinnerAdapter.html#getDropDownView%28int,%20android.view.View,%20android.view.ViewGroup%29"><$c$c>getDropDownView方法了。这使您可以提供一个不同的视图下拉列表中的度量标准和格式,你想要的。

考虑夸大的框架布局 android.R.layout.simple_spinner_item android.R.layout.simple_spinner_dropdown_item 的这些情况。使用 findViewById(android.R.id.text1)获得的TextView 应填写在每一个。

In android you could set a navigation list in action bar by passing spinner adapter and OnNavigationListener. the issue is that the navigation list dont fill most of the action bar, how to make it expand like the gmail app : Example of Gmail app :

My app:

And here's the code :

//... setting the array adapter
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
NavigationListener navigationListener = new NavigationListener();
ListAdapter listAdapter = new ListAdapter();
actionBar.setListNavigationCallbacks(listAdapter, navigationListener);
actionBar.setDisplayShowTitleEnabled(false);

Other problem i face is the size of the spinner item, they show up really small, is that because i dont pass customized textview (look at screenshot)? example of what i do :

private class ListAdapter extends BaseAdapter implements SpinnerAdapter {

    public View getView(int pos, View view, ViewGroup viewGroup) {
        TextView text = new TextView(context);
        text.setText(arrayAdapter.getItem(pos).toString());
        return text;
    }

}

解决方案

You want to implement the getDropDownView method too. This lets you supply a different view for the dropdown list with the metrics and formatting you want.

Consider inflating the framework layouts android.R.layout.simple_spinner_item and android.R.layout.simple_spinner_dropdown_item for these situations. Use findViewById(android.R.id.text1) to get the TextView you should fill out in each one.

这篇关于如何扩大导航列表中的动作栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆