• 7
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

ADT blank activity created with fragment activity..

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 activity without the fragment one...

in the first image the blank activity comes with the fragment layout..

first image blank activity

the second image shows the created fragment_main

second image blank activity

now i am really confused... this only happened after updating ADT to the latest version i have referred to this thread: https://stackoverflow.com/questions/22203862/adt-doesnt-create-default-hello-world-but-command-line-does#=

i just wanted to make an android app with blank activity with no fragment view...

For those who would like instructions on how to remove Fragments from the project:

1) Copy all the contents of res/layout/fragment_main.xml. Open activity_main.xml, delete the FrameLayout, and paste in the copied contents.

2) Delete fragment_main.xml

3) In MainActivity.java, delete the whole PlaceHolderFragment class:

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

4) Delete the following lines from onCreate():

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

At this point you should be all set to run the project.

  • 27
Reply Report

You can use the previous template by editing the template files inside the Android SDK folder. But, make sure you have a backup of the "BlankActivity" folder.

  • Go to /templates/tools/templates/activities/BlankActivity

  • Locate the template.xml file and locate the following piece of code

     <parameter
      id="fragmentLayoutName"
      name="Fragment Layout Name"
      type="string"
      constraints="layout|unique|nonempty"
      suggest="fragment_${classToResource(activityClass)}"
      default="fragment_main"
      help="The name of the layout to create for the activity's content fragment" />
    

and change the constraints to constraints="empty".

  • Locate recipie.xml.ftl and locate the following piece of code
    <instantiate from="res/layout/fragment_simple.xml.ftl" to="${escapeXmlAttribute(resOut)}/layout/${fragmentLayoutName}.xml" />
    and comment the whole line.

  • Locate SampleActivity.java.ftl file inside root/src/app_package and delete these two lines
    <#include "include_options_menu.java.ftl"> <#include "include_fragment.java.ftl">

  • Locate fragment_simple.xml.ftl and activity_fragment_container.xml.ftl file inside root/res/layout. Copy the contents of fragment_simple.xml.ftl file to activity_fragment_container.xml.ftl file.

Now when you try to create a new activity, you'll get this screen new activity without fragment

You can leave the Fragment Layout Name field blank.

This works fine for me in the case of blank activity. I'm not sure if this is the right approach, with discarding fragments and all, but this works for me.

  • 7
Reply Report

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

  • 6
Reply Report

Thank you to the person that reported this, https://code.google.com/p/android/issues/detail?id=67513

This was my first glimpse into android-review.googlesource.com. Digging around I didn’t see a way to download the patch set that was put together and I’m unsure how to “cherry pick” tools_r22.6, If there's a thread that explains it a link would be appreciated.

Here’s how I went about it.

On your machine navigate to your SDK folder then \tools\templates\activities

Copy the BlankActivities folder and paste it into the same directory.

Rename BlankActivities_copy to EmptyActivities

Go to https://android-review.googlesource.com/#/c/88890/4

Under the Files section there is a list of links. Each link directs you to the xml that needs to be added to the new EmptyActivities folder you created.

Copy the xml from the right pane to the path\file at the top of the left pane(the link was also the path). If the file already exists delete the contents and replace. If the file doesn’t exist, create it and copy the xml into the file.

Repeat for each of the links.

Close and reopen Eclipse. If you have any of the files open in an editor Eclipse will crash.

Thank you to Josiah Gaskin at google with the unbelievable 2 day turnaround!

No training literature references the fragments in the BlankActivity. I’m sure this fix saved me countless hours trying to figure out how to navigate around fragments while trying to learn a new IDE. Thanks again.

  • 5
Reply Report
      • 2
    • Ahh.. finally, THanks!! But it doesn't generate layout.xml file for the activity. ANy solution for that?
      • 1
    • On the create activity screen "Empty Activity" should be an option. After picking it and clicking next the Empty Activity form has a default Layout Name of "activity_main" that will show up as res/layout/activity_main.xml in Eclipse.

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.

  • 3
Reply Report

If you don't want the fragment part to be in your app then simply "unckeck the create activity option at project setup wizard, then manually create the activity and layout" for your project.

  • 3
Reply Report
    • when you try to create a New Activity separately (manually) by right clicking on your package name and selecting Other->Android Activity, the fragment field still comes up and requires you to name it.
      • 2
    • When creating a new project, you will have an check-box for activity, un-check it. Later you create activity and layout manually(google to know how to create activity manually)
    • i know how to create an activity manually... its just annoying that the fact you need to manually create it instead of the ease of doing it automatically.. thanks btw!

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.

  • 3
Reply Report

We found a solution to this:

When you create a project select "empty" activity. Then it create a MainActivity class that extends Activity and an activity_main.xml layout.

In other words, it give you the behavior that was there before.

This worked in ADT 22.6.3.

  • 3
Reply Report

While creating a new Application, just copy the Layout Name to the Fragment Layout Name (e.g. activity_main)

Voila!!! You get an activity without the fragment part.

Remove this portion of the code from activity:

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

Clean the project.

  • 2
Reply Report

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

  • 1
Reply Report

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

  • 1
Reply Report