• StartActivityButtonListener 很简洁 值得学习


        @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initUI();


    }

    private void initUI() {
    setContentView(R.layout.main);
    findViewById(R.id.toCheckboxSnippetButton).setOnClickListener(
    new StartActivityButtonListener(
    MultiSelectionAndEditableActivity.
    class));
    findViewById(R.id.toProgressbarListSnippetButton).setOnClickListener(
    new StartActivityButtonListener(ProgressbarListActivity.class));
    findViewById(R.id.toPageLoadButton).setOnClickListener(
    new StartActivityButtonListener(PageLoadActivity.class));


    }

    class StartActivityButtonListener implements OnClickListener {
    Class
    <? extends Activity> targetActivity;

    StartActivityButtonListener(Class
    <? extends Activity> targetActivity) {
    this.targetActivity = targetActivity;
    }

    @Override
    public void onClick(View v) {
    startActivity(
    new Intent(MainActivity.this, targetActivity));
    }

    }

    /*改代码是转载的*/
  • 相关阅读:
    QTdebug时没有调试引擎
    快速排序
    MFC之动态创建按钮
    Linux 本人常用到的基本命令
    history 查看历史操作记录在shell脚本执行中无法显示问题
    C#基础学习5
    C#基础学习4
    C#基础学习3
    C#基础学习1
    C#基础学习2
  • 原文地址:https://www.cnblogs.com/xiaobuild/p/2144738.html
Copyright © 2020-2023  润新知