I am using android studio to design an application. I have created a few java classes and want to put them in different packages. I have already created the java classes and have implemented the code inside them. However, now, I want to put them under different packages according to their utility. How can I do that?
In short, I want to go from here:
to here:
Sorry for the blurry image, I took it from a video tutorial.
There are different things you can do:
Drag the java classes and drop them into the package you want
Open the app folder from your computer files searcher and just ctl + x the .java files and paste them in the folders you want(creating a new package)
Create new java files inside the packages you want and just copy the code from the java files located wrongly. After that delete the java files you don't need.
Hope it helps.
Related
I want to know if we can create just one Localization folder for my application in MVVMCross (Android, IOS, Core) to change the language.
In fact, i watching this video/tuto to change my Application Language with MVVMCross: https://youtu.be/VkxHtbJ_Tlk
I downloaded the sample too and i can see, his folder BabelResources is in his Android project, in his IOS Projet, in WPF etc...
I can't create just one ressource folder and create just one JSON file with my translation (In my PCL for example)
Thank for your help
http://opendix.blogspot.dk/2013/05/using-resx-files-for-localization-in.html
or`
http://enginecore.blogspot.dk/2013/09/localization-in-xamarin-mvvmcross_18.html
or
http://blog.giovannimodica.com/post/internationalization-of-a-cross-platform-application
Hope one of them can help you on your way :) Alternatively, you could add the translation file in for example the android project and add it as link in the ios project.
Here's an alternative using simple text files in your PCL: https://github.com/xleon/I18N-Portable
The video tutorial you're referring to is using linked files in other projects. So you setup up only one resource file and use it in all the platform projects by linking to the file (instead of copying it)
You can find the source here: https://github.com/MvvmCross/MvvmCross-Tutorials/tree/master/Babel
Since my application is growing more and more dense each day. I thought of re-structuring various files.
By re-structuring, I mean to add folders seperately for screen activites, another folder for dialog xmls, screen xmls, for custom adapters, etc. In other words, I need to segregate files according to their significance.
Currently, all my java files are listed in src folder (screen activities, custom adapters, business logic, etc.) and all the xmls (screens, custom list view design, custom dialogs, etc.) are present in layout folder.
Is it feasible? What impact will it have on the existing project?
Folders are synonymous with packages -- that's how the IDE interprets them. So putting them in separate folders actually creates separate packages. That's the downside, they won't have the same scope/permissions as if they were in the same package.
Packages in Java
What you're talking about is most likely packages.
Packages makes structuring of bigger projects and navigating through it much easier.
However you can't without writing your own gradle extension put your XML files outside /res/ folder, but codewise, wrapping your classes in packages makes working in bigger codebase much easier
You define the package you class is in before defining the imports in following way:
package com.ruuhkis.test;
import android.content.Context;
class Test {
}
then the Test class is put in folder /src/com/ruuhkis/test/ folder to be found by the compiler
I've created an app which pulls data from a JSON file and displays it.
Now that app is specific for one sports team. I want to create the same app for 10 other teams.
Plus there will be an accompanying pro version of the app.
I'll be doing the same thing for the iOS version.
The only difference between the apps will be colors, logos and url of the data source.
I wanted to know if there was a better way to create apps. Instead of individually creating 40 different projects.
It will help me in updating the app as opposed to copy pasting the same code 40X.
Are there any special features available in eclipse and xcode to do that?
Thanks
I would simply swap out the resources for each team and rebuild the app.
For example, with Android, maintain an AndroidManifest.xml and a res/ subdirectory tree for each team. When it is time to build, simply copy over the resources into the project, overwriting the previous team.
I don't know of any existing tool to do this automatically, however.
Have you looked into using PhoneGap and just create a "mobile site" that detects the app that is connecting and adjusts the data/styles accordingly.
There's always the possibility of creating ONE app allowing the user to set the team preference upon first load, and swapping out resources programmatically.
With Titanium Studio you can write code using Javascript and it convert your code in native objective-c code, native android code, native html 5 code and soon also in windows phone code. It`s the best free cross platform IDE
Upon reviewing your responses, you seem to want a strategy to manage your resources. Since different OS has different resource requirements (screen-size, iOS 2x png for example). The most common strategy is to keep a separate resource structure and setup build target to copy/xcopy replace these image resources before build. Source control + an OSX build server would be most beneficial.
After creating these apps I've found the following way to be the most easiest way to create a similar app.
Android:
1. Select the project from the project explorer sidebar copy it and then paste it. Give it a new name.
Select the new project and then right click > Android Tools > Change Package Name.
Give it a new package name. Eclipse will give you an option to refactor the code, say yes.
Go to res/values and change all strings.
Change the icons and other images.
Go to src click the package and then refactor it. Give it the new package name.
Go to manifest file and rename any old names which might still be lingering.
My goal is to create multiple android APKs. All that is different is the package name and I manually override some things in the res folder.
I understand you can do a library project. The problem with that is we have to manage multiple manifest files and the version with that. That is not what I want to do.
I was looking into aapt to create the new package name and shared res folder. The problem is I do not know where to start. I see lots of examples like:
Custom Android build.xml for rename manifest package
also below is exactly what I want to do:
http://blog.uncommons.org/2010/07/19/building-two-versions-of-the-same-android-app/
Can anyone provide direction on where to start?
The best way to do this is to create a library project, and than create separate projects for each of the APKs that you want to have. Each APK project can than have its own Manifest and reference the Library Project. Believe me when I tell you that this is much easier than trying to rename packages during build/compile time. You can easily call into activities that are shared in the library package just as long as you use the fully qualified name in the individual APK's manifest file.
http://developer.android.com/tools/projects/projects-eclipse.html
I had the same problem before and made a batch file to copy files like images, mp3 files, etc. to the workspace folder where I have my application folder in it. You have to make everything dynamic if you don't want to use the library project. I hope this helps, else you can ask me anything you want.
I have an app on the iPhone and need to port it to android. For this I would like to group screen related files like classes and xml per screen in one "screen group" per screen somehow, ideally also strings and other value files
if I use folders I can only group res files separately and src files separately.
what would be the best way?
Thanks very much!
EDIT:
If that should not be possible, how to best then solve this issue? Do you create a subfolder in the src and another in the res for each screen?
The way you group files for the iphone is not possible for an android project. Android has pre determined folders which hold specific files, if you break this structure, your building process will fail. Its not ideal but that just how it it.
When it comes to source java files, they follow the concept of packages which are basically folders. The 'src' folder is the part where you can create sub folders as you desire. If you are adamant about keeping the files related to a screen in one place, you should create the layouts with java code and not use layout xml files.
But using xml layout files make development much easier and faster. Consider that as the presentation and java files as the logic+data. So group java files as you want and leave xml files in the layout folder with easy to identify names.
android uses certain directory layout for project structures (i.e. convention over configuration). Basically you will want to put your XML layout files in res/layout directory. Please read http://developer.android.com/guide/developing/projects/index.html#ApplicationProjects for further information.
Unfortunately, there's no easy way to do this in Eclipse. You can't create custom directories in your Android app's /res directory, you can only use permitted dir-names. E.g. you can't have a /res/layout-myscreen1 and /res/layout-myscreen2. You also must put your resources in /res, and your code files in packages, so they're at separate places in your project.
You can use Working Sets to group related files together however, but they're quite painful to use IMHO. Check the eclipse docs and tutorials out on them.