当前位置: 代码迷 >> Android >> onOptionsItemSelected 中使用Intet不跳转解决思路
  详细解决方案

onOptionsItemSelected 中使用Intet不跳转解决思路

热度:101   发布时间:2016-04-27 22:49:06.0
onOptionsItemSelected 中使用Intet不跳转

 public boolean onOptionsItemSelected(MenuItem item) {
        String str = null;
        String result = null;
        Intent intent;
        ActionBar actionBar = getActionBar();
        switch (item.getItemId()) {
            case R.id.sweep:
                intent = new Intent(ActionBarExActivity.this,SweepActivity.class);
                startActivity(intent);     //就是不跳转,我的AndroidMainifest.xml是写了SweepActivity这个 的,也不报错
                ActionBarExActivity.this.finish();
                break;
            case R.id.scrub:
                str = "youxi.txt";
                result = getString(str);
                textView6.setText(result);
                break;
            case R.id.vacuum:
                str = "yingyong.txt";
                result = getString(str);
                textView12.setText(result);
                break;
            case R.id.kaifa:
                str = "3d.txt";
                result = getString(str);
                textView9.setText(result);
                break;
        }
        return true;
    }

------解决思路----------------------
你把下面的finish去掉试下,打印下日志,看有没有执行到