Vla*_*usB 15 android spinner android-actionbar drop-down-menu
如何在操作栏中使微调器具有所选的不同项目(显示在操作栏顶部),然后是下拉列表中的项目?示例是带有微调器的google mail在操作栏中:
任何源代码,教程或文档都会非常有用.我已经在操作栏中有绑定微调器和适配器,我在下拉菜单中有列表,但我不能以任何方式修改项目而不影响下拉列表中的项目(因为它们是相同的东西).
ale*_*leb 20
要在操作栏微调器中具有与微调器列表中不同的视图,可以使用BaseAdapter或ArrayAdapter并覆盖某些方法:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Return a view which appears in the action bar.
return yourCustomView..;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
// Return a view which appears in the spinner list.
// Ignoring convertView to make things simpler, considering
// we have different types of views. If the list is long, think twice!
return super.getView(position, null, parent);
}
Run Code Online (Sandbox Code Playgroud)
它可能有点太晚了,但可以在Android开发者网站上找到带注释代码的教程:http: //developer.android.com/guide/topics/ui/actionbar.html#Dropdown
基础知识是,在活动OnCreate期间,您必须将其设置为列表:
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
Run Code Online (Sandbox Code Playgroud)
然后创建一个微调器适配器和一些回调,就像使用普通微调器一样.
希望能帮助到你
| 归档时间: |
|
| 查看次数: |
15212 次 |
| 最近记录: |