2014-02-05 29 views

回答

0

使用Custom Suggestions在菜單XML的動作條

<?xml version="1.0" encoding="utf-8"?> 
<searchable xmlns:android="http://schemas.android.com/apk/res/android" 
    android:label="@string/app_label" 
    android:hint="@string/search_hint" 
    android:searchSuggestAuthority="com.example.MyCustomSuggestionProvider"> 
</searchable> 

或創建佈局autocompletetextview並添加布局充氣並設置setCustom

ActionBar actionBar = getActionBar(); 
    actionBar.setDisplayHomeAsUpEnabled(true); 
    actionBar.setDisplayShowCustomEnabled(true); 
    LayoutInflater inflator = (LayoutInflater) this 
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View v = inflator.inflate(R.layout.yourlayout, null); 

     actionBar.setCustomView(v); 
+0

Autocompletetextview是解決 – Rafael

+0

我認爲這是更簡單的actionBar.setCustomView(R.layout.yourlayout); – Rafael