How to modify dummy content in android master/detail activity?

前端 未结 3 696
春和景丽
春和景丽 2021-01-02 21:23

I would modify the items generated by eclipse in the master/detail schema. I can\'t find a way to do this. In particular I would take the items from an xml (res/values/array

3条回答
  •  感情败类
    2021-01-02 21:55

    This is something that worked for me, not sure if it is the best practice. Remove the static block and on the ItemListActivity.java on the Oncreate add this code

    protected void onCreate(Bundle savedInstanceState) {
    
        super.onCreate(savedInstanceState);
    
        if (DummyContent.ITEMS.isEmpty())
        {
            DummyContent.addItem(new DummyItem("1", getResources().getString(R.string.menu1)));
            DummyContent.addItem(new DummyItem("2", getResources().getString(R.string.menu2)));
            DummyContent.addItem(new DummyItem("3", getResources().getString(R.string.menu3)));
        }
    

    Hope this helps

提交回复
热议问题