So I just started with Android studio and i am following the Android NanoDegree from Udacity and in one of the lessons i am supposed to create a Blank activity with fragment which does not exist any more i understand that the Empty activity is the same as the Blank activity i have searched and all i could find was old questions and the answer was to choose an empty activity then check the add fragment option but i can't find the fragment option at all (See Image).
Can any one tell me what i should do to match the required activity from the lesson ... it has MainActivity.java and fragment_main.xml and activitymain.xml and a place holder fragment in the mainactivity.java file
In Android Studio, if you right click on your project in the project view, under New -> Fragment -> Fragment (blank).
I tried to add a screenshot but I'm not allowed yet.
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 :)
Per the question here,
What's "tools:context" in Android layout files?
The 'tools' namespace reference (xmlns:tools="http://schemas.android.com/tools") has begun to appear in my layouts recently, and I want to know more. The original post only described the 'tools:context' attribute, but I have also noticed usage of the "tools:listitem" attribute appearing when I have designated a preview layout item for a listview, i.e.
<ListView
android:id="#+id/lvCustomer"
tools:listitem="#layout/customer_list_item" >
</ListView>
Are there more elements?
What brought me to this 'tools' namespace is that I want to be able to have 'preview-only' text (i.e. in a TextView or EditText) when using the layout designer in eclipse.
Currently, I assign the 'text' or 'hint' property for previewing text when arranging my layouts... but then I always have to remember to clear the preview value from within the code.
Ideally, instead of
<string name="preview_customer_name">Billy Bob's Roadhouse Pub</string>
...
<TextView
android:id="#+id/tvCustomerName"
android:text="#string/preview_customer_name"
</TextView>
have a something like:
<TextView
android:id="#+id/tvCustomerName"
tools:previewText="#string/preview_customer_name"
</TextView>
Thanks-
We've just added support for designtime attributes like this in Android Studio 0.2.11. See http://tools.android.com/tips/layout-designtime-attributes for more.
Think of them as design time helpers only.They do not get processed in actual view rendering at run time.
For example you want to set background of some view in your layout design when working on android studio so that you can make clear distinction where that particular view is.So you would normally do that with
android:background="#color/<some-color>"
Now risk is that sometimes we forget to remove that color and it gets shipped in apk.
instead you can do as follows:
tools:background="#color/<some-color>"
These changes will be local to android studio and will never get transferred to apk.
And also check out http://tools.android.com/tech-docs/tools-attributes for more options.
You will find tool attribute when you set object in graphical layout.
Listview (in graphical mode) -> right Click -> Preview List Content -> Choose Layout...
produces:
tools:listitem="#layout/customer_list_item"
See in layout XML below. There are 2 namespace in use "xmlns:android" and "xmlns:tools".
Tools namespace is used when the developer wants to define placeholder content that is only used in preview or in design time. Tools namespace is removed when we compiled the app.
So in the code below, I want to show the placeholder image (image_empty) that will only be visible at design time, and image1 will the actual image that will be shown when the application launch