LanucherActivity使用总结

来源:互联网 发布:闪电的利用知乎 编辑:程序博客网 时间:2024/06/05 02:49

LanucherActivity:

LauncherActivity的作用在于形成一个列表,然后每一个列表点击产生一个intent条状到相关的界面去;

    // 定义两个Activity

    Class<?>[] clazzs = { PreferenceActivity.class, ExpandableListActivity.class };

 

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);

        Item item1 = new Item("菜单一", 1);

        Item item2 = new Item("菜单二", 2);

        List<Item> list = new ArrayList<Item>();

        list.add(item1);

        list.add(item2);

        LauncherAdapter adapter = new LauncherAdapter(this, R.layout.launcher_item, list);

        this.setListAdapter(adapter);

    }

 

    @Override

    protected Intent intentForPosition(int position)

    {

        return new Intent(this, clazzs[position]);

    }

 

可以通过改写adapter形成自己要的样式;

0 0
原创粉丝点击