如何扩大导航列表中的动作栏?动作、列表中

2023-09-12 21:53:29 作者:指着心脏说胃疼@

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

我的应用程序:

和这里的code:

  // ...设置阵列适配器
动作条动作条= getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
NavigationListener navigationListener =新NavigationListener();
ListAdapter listAdapter =新ListAdapter();
actionBar.setListNavigationCallbacks(listAdapter,navigationListener);
actionBar.setDisplayShowTitleEnabled(假);
 
WPS演示制作下拉式列表导航模板

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

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

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

}
 

解决方案

您要实现的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.