而不是创建一个新的活动的Andr​​oid,这将创建片段活动 [英] Android, instead of creating a new activity, it creates an activity with fragment

查看:97
本文介绍了而不是创建一个新的活动的Andr​​oid,这将创建片段活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android应用程序,而上周我更新了几包(不记得哪些完全一致)使用SDK管理器。重新启动Eclipse中,每当我创建一个新的活动(与用于仅包含的onCreate和onCreateOptionsMenu方法)后,它创建了一个活动与这两种方法,再加上如下因素code:

I am developing an Android app, and last week I updates a few packages (dont remember which ones exactly) using SDK Manager. After restarting Eclipse, whenever I create a new Activity (with used to contain only onCreate and onCreateOptionsMenu methods), it creates an Activity with those two methods, plus the folowing code :

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_lmain,
                container, false);
        return rootView;
    }
}

我是新与Android所以林不知道这是为什么hapening以及如何撤销这些变化,以便能够像以前一样创建一个正常的活动。

I am new with Android so Im not sure why is that hapening and how to "undo" those changes in order to be able to create a "normal" Activity as before.

鸭preciate任何帮助,谢谢。

Appreciate any help, thanks.

推荐答案

我觉得你使用的是Android Studio和,是的,Android的工作室并创造一个片段,当你创建你的应用程序一个额外的方法。

I think you are using Android Studio and and yes, Android Studio does create one fragment and an extra method when you create your application..

这不是一个问题,..你可以直接删除那个fragment.xml之和额外的code这是与一些条件和片段整个另一种方法。

It's not an issue,.. you can just delete that fragment.xml and that extra code that's with some condition and the whole additional method for the fragment.

然后,它会被罚款。我不知道到底为什么它发生在Android的工作室。

Then it will be fine.. I don't know why exactly it happens in Android Studio.

这篇关于而不是创建一个新的活动的Andr​​oid,这将创建片段活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆