Android:从SherlockActivity回到SherlockFragment

时间:2012-10-14 14:27:07

标签: android android-activity android-fragments actionbarsherlock back

我正在打开一个来自SherlockFragment的SherlockActivity。 现在我想用后退按钮构建一个Actionbar。这有效:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myactivity);        
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
}

但是我怎么能回到我的Sherlockfragment?这不起作用。错误代码是“无法找到显式活动类”

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
            case 0:
                return true;
            default:
            // This do NOT bring me back to my SherlockFragment !!! //
                Intent in = new Intent(this, MySherlockFragment.class);
                startActivity(in);
                return super.onOptionsItemSelected(item);
            }
}

如何从SherlockActivity中启动Sherlockfragment?

谢谢: - )

0 个答案:

没有答案