ADT blank activity created with fragment activity..

后端 未结 15 1850
鱼传尺愫
鱼传尺愫 2020-11-28 05:55

i am really confused right now because whenever i create a new android app with blank activity it always comes out with fragment_main.xml.. i just wanted to create a blank a

相关标签:
15条回答
  • 2020-11-28 06:10

    A blank activity really should be more simple than this. It appears that a fix is currently pending: https://code.google.com/p/android/issues/detail?id=67513&q=blank%20activity&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

    You can skip the create activity option when you create your project and add in an activity manually.

    If you find it really really annoying you can try rolling back ADT and the SDK:

    Download the 22.3 sdk tools from: dl-ssl.google.com/android/repository/##Your platform's version of the sdk here##

    For example osx is tools_r22.3-macosx.zip

    Unzipping that file will give you a folder called "tools" Use this to replace the folder of the same name found in /path-to-your-android- installation/android-sdk-macosx/

    Next you need to uninstall your eclipse adt plugin. Go to help -> install new software Click the link to see what's installed already Select all of the android packages and click uninstall. Restart Eclipse

    Download the 22.3 ADT plugin from: http://dl.google.com/android/ADT-22.3.0.zip Unzip this file

    Back in eclipse click help -> install new software Click add and select the local file you just unzipped Check what you want to install and click install Restart eclipse again

    0 讨论(0)
  • 2020-11-28 06:10

    I done it by replacing the BlankActivity(22.6.2) folder to the older sdk BlankActivity(22.6.1) present in the tools/templates directory in android-sdk.

    0 讨论(0)
  • 2020-11-28 06:10

    Not sure if this works completely, Steps 1) Right click on your project goto properties->Android, remove reference library and press apply. now you would see errors in your project go to res->values->styles, replace AppBasetheme's parent by parent="android:Theme.Light" do this for all values folder except in values_v14 there put parent="android:Theme.Holo.Light.DarkActionBar"

    2) Now goto MainActivity replace "extends ActionBarActivity" by "extends Activity". Eclipse will prompt you to import for activity do it.

    now delete this part of code

    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_main, container,
                    false);
            return rootView;
        }
    }
    

    from activity class

    if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
    

    Now remove all unused imports.

    3) Goto res->Layouts->fragment.xml, copy code of fragment into activity_main.xml. Delete fragment.xml.

    Now goto main.xml Replace this

        <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        app:showAsAction="never"/>
    

    by

        <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        android:showAsAction="never"/>
    

    4) Now Click on Project and clean your project

    0 讨论(0)
  • 2020-11-28 06:13

    A solution to this, is a copy of the older "Blank Activity" in %Wherever your ADT bundle is%\sdk\tools\templates\activities\.

    If someone has an older version of it, you can rename it, place it in here %Wherever your ADT bundle is%\sdk\tools\templates\activities\ and then when starting your project, select this folder instead of "Blank Activity", so if you have a copy please share.

    0 讨论(0)
  • 2020-11-28 06:17

    This is a new feature of ADT version 22.6.0: http://developer.android.com/tools/sdk/eclipse-adt.html

    Edit: With the latest ADT updates there is a new template called "Empty Activity" that has no fragments. it's a plain class that extends Activity (Even without the default menu).

    Notice that there is also a "Blank Activity" which extends ActionBarActivity and has fragments

    0 讨论(0)
  • 2020-11-28 06:18

    I have also faced the same issue. I just deleted the eclipse and again downloaded the ADT bundle from http://developer.android.com/sdk/index.html#download To recover your previous projects, just change the work-space to your previous one. This worked for me.

    0 讨论(0)
提交回复
热议问题