簡體   English   中英

具有ListActivity的Material Design工具欄

[英]Material Design ToolBar with ListActivity

我正在替換ActionBar ,並將Material Design ToolBar集成到我的應用程序中。 我的活動之一是ListActivity的擴展。

onCreate()方法中,每當我嘗試添加ToolBarsetSupportActionBar()方法都會產生一個錯誤,指出無法解決。

    @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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM