The new Android Studio update came out sometime last week (January 2019 Version 3.3).
In the previous version you'd be able to create new project and click a checkbox that said "add a fragment".
Unfortunately, in the new update I can't find this checkbox or anything related.
Do we now have to add fragments by hand? Or is there a way to create a project with a fragment?
I found the solution.
Before Version 3.3 you were able to create a new project and set the basic activity as a fragment. Since Version 3.3 update it no longer gives you the option to create a fragment when creating a new project.
So this is how you're supposed to do it:
Create a new project with whatever activities you want.
Switch to Android View -> Right click on "app" under the navigator -> New -> Activity -> Basic Activity
Now a separate window will open up and you're able to select the checkbox "Use a fragment".
Another way to do it while retaining the current Activity is to auto generate the fragment using
New (or Alt+INS) -> Fragment -> Fragment (any of the subtypes).
this will generate your frament xml layout together with the code stub.
Then in the main_activity.xml replace the "helloWorld TextView" (if you create an empty activity) or "content_main.xml" (if you create the one with FAB) with the following...
<fragment
android:id="#+id/fragment"
android:name="com.example.MainFragment"
tools:layout="#layout/fragment_main" />
assuming you name it as MainFragment in the com.example package.
I'm trying to integrate Google Calendar API into my android project and I follow the tutorial here
https://developers.google.com/google-apps/calendar/quickstart/android
At step 5 create a new java class
I right click project folder src>main>java>com>example>utarapp and then new>file and entered the file name but then it has this error
What's going on ?
I'm using android studio 1.3.1
I think you are trying to create file with same name which is already present in the same package. This may be one possible reason.
It seems like you are right-clicking on the upper level in your application's directory tree.
Right click on one of the files inside the utarapp folder and then select Java class option from the menu.
For me this was happenning because of the length of the class name. In my case it was "ChallengesFragmentPagerAdapter"!
Changing it to "ChallengesPagerAdapter" solved the problem.
Create a blank Activity then remove "extends Activity" from the activity class.
I am writing a new better version of my old Android project that will fix a lot of UI bugs but also has a better design, needed for integration of some new features.
As I go through the source I can see all my old and new TODOs in the source, but there are things I remember and forget I want to do in the future and don't fit in any source yet.
Eclipse had a simple list of Tasks in the project on which you could write down and track all bug fixes and new features you wanted for that project. Very handy!
Is there a way add such tasks/issues/notes/todos in Android Studio in the project in general, WITHOUT adding them at a specific place in the sources?
To add a ToDo, just comment anywhere in your code starting with the word ToDo
//Todo: Get count from database instead
To view the list of ToDos, look in the bottom left corner of your Android Studio window:
if you open it, you will get this view with the list of your todos and options to navigate to files where they are located in your project:
go to View -> Tool Windows -> TODO to display the TODO panel
Anything marked
// TODO
should be visible in the list panel
Edit:
You can add plugins for task management in Intellij 14
https://www.jetbrains.com/idea/help/managing-tasks-and-context.html
I've not used them as our workflow is outside the IDE and I can't comment on whether they will work as intended in Android Studio.
Here's how I do this: I create a text file called "TaskList.txt". I put it in the java/res package. (Not necessarily appropriate for this package, but I haven't felt like creating a package just for this purpose.)
Like any code file, you can start a line with
//TODO
and the IDE will recognize it as one of your tasks. You can have dozens or hundreds of TODO's in this file. And, of course, you can still have TODO's embedded in your code files, closely-associated with the code you need to update/correct.
My TaskList.txt TODO's show up in Android Studio's TODO view (bottom-left corner of the IDE or View -> Tool Windows -> TODO) along with all my embedded TODO's.
In order to set check points for yourself inside the android studio project, you may do it as:
In Java File:
// TODO: I am waiting for you to be fixed ;)
OR
//FIXME: fix me before release :)
In XML File:
<!-- TODO! Hey I am here down in XML -->
some one above commented that todo is not working inside xml file so it is for them.
You can view them in your android studio window of TODOs:
and all todos from your project will be listed like:
You can use either of TODO, FIXME, etc. but it's not possible to do that without using them inline in your code. use them as follow:
{
...
some code //FIXME
...
}
or
{
...
some code //TODO
...
}
Here's a cheat sheet for some popular IDEs:
IntelliJ IDEA-based IDEs (e.g. Android Studio): TODO, FIXME
Visual Studio: HACK, TODO, UNDONE and NOTE.
Eclipse: #todo, FIXME, TODO and XXX.
Netbeans: TODO and FIXME
Code::Blocks: At least TODO.
Rider: TODO and BUG
Android Studio: TODO and FIXME
P.S. feel free to edit this answer by adding your fav IDE comment
tokens.
Write (todo) after than press tab key
According to this link, you can define all of your own comment tags (TODO, FIXME, OPTIMIZE, OPTIONAL, etc).
Android Studio -> Settings/Preferences -> Editor -> TODO
Red - Add your own patterns using the \bpattern\b* format
Green - Add custom filters. These filters show up in the filter list at the bottom of Android Studio on the TODO tab.
EDIT better use Alternative to avoid app crash
Alternative: You could write it like this: //TODO: "your todo here", and it'll also appear on TODO tool windows
In Android Studio (I'm using v2020.3.1), you could do (... = your normal codes):
...
TODO("your todo here")
...
TODO comment example
TODO comment example alternative
It will show up on the TODO tool windows (View -> Tool Windows -> TODO)
Todo lists window
Todo lists alternative window
NOTE: It could cause your app to crash if your code read it as a function call (Error code/function not implemented yet)
In Android Studio under the Tools menu there is the option for Tasks&Contexts. You can manually add tasks (i.e the todo's you want to perform for your project). It is quite simple, just add a task title, a VCS branch name and changelist, so might not suit your needs. Follow this link to learn more.
My favorite way is like the following:
<!-- //TODO: Poczytać o rodzaja Layoutow -->
//todo works as well for java in android studio.
No need for capitalization.
This will make your ease
<!-- TODO: Update blank fragment layout -->
I found this plugin
https://plugins.jetbrains.com/plugin/14966-todo4me
You can keep track of local work without add a //todo comment.
Sometimes as you said, you just need to keep track of small tasks and you don't want to use tools like jira.
When I right click Content folder of my project then Add -> new Element, in the dialog box, selecting XNA Game Studio 4.0 I see only 3 templates, which are:
content type writer
content processor
content importer
Since every tutorials that help in creating screen menus say that I should start by loading SpriteFont template, I think that I've missed something.
Any suggestions? Should I give you more informations?
You have to right click your Content project -> add -> new element. If you don't have a Content project you can create one, just right click on your solution -> add -> new project -> XNA Game Studio 4.0 -> Empty Content Project (4.0)
You have to click the solutionname Content node and not the solutionname node. The new items result is based on that.
In my example, right-clicking the PickingContent node>add new items gave me the correct list.
And yes, we're probably doing the same tutorial :)
Is there a way to change the built-in templates?
Concrete example: I want to change the template that is used when creating an event invocator. I want to change the visibility of the generated method as well as the the name.
Go to template explorer ( ReSharper > Tools > Template explorer )
Search the desired template and click on Edit Template or double click to open it.
Edit the template as you want and save it.
More info here