[英]Material Design ToolBar with ListActivity
我正在替換ActionBar
,並將Material Design ToolBar
集成到我的應用程序中。 我的活動之一是ListActivity
的擴展。
在onCreate()
方法中,每當我嘗試添加ToolBar
, setSupportActionBar()
方法都會產生一個錯誤,指出無法解決。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_route_recipients);
// Attaching the toolbar layout to the toolbar object
toolbar = (Toolbar) findViewById(R.id.tool_bar);
// Setting toolbar as the ActionBar with setSupportActionBar() call
setSupportActionBar(toolbar);
// get the default list view associated with this activity
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); // we can now check and uncheck multiple friends
// get the array of LatLng points passed in from the map intent
markerPoints = getIntent().getParcelableArrayListExtra("markerPoints");
}
解決此問題的最佳方法是什么?
您寫道,您的活動擴展了ListActivity
但不幸的是ListActivity
沒有實現setSupportActionBar
。 您必須基於AppCompatActivity
活動。
您會說“但是,嘿,但是我確實需要ListActivity
因為我已經在Activity中添加了ListView
” –也考慮使用RecyclerView
。 我想說ListView
現在是死胡同-應該將代碼移植到RecyclerViews
作為幫助,兩個示例項目展示了Material Design的所有新功能
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.