I need create many similar simple applications (Android and iOS) that consist of four tabs, each tab contains listview but it must be offline.
The difference between the apps will be only the content of the list and tabs names.
what is the best way to design this app ?
The first idea was putting configuration file and the app will load the info from there.
For sure i'm not the first dealing with this issue, maybe there is already solution or design for such problems ?
Maybe there is solution to load the content in compile time and not in run-time (as in my solution) ?
Thanks.
You can create a class containing all the information you want and you can use the data from that class instead of configuration file, and you can replace that class file for each individual app you create. This will be done at compile time rather run-time.
For run time best is to go with plist files for iOS and xml/properties file for android
For Compile time create a Class containing all data and replace it for each application version
Related
im new to android and im trying to make a "simple" app.
However i would like to know if, what i have planned, is possible in android.
Basicly it's a crude database reader/navigator.
I made a folder structure in the assets folder with a few directories and *.txt files.
Now the plan is to read/scan the folder structure on startup of the program and dynamicly create buttons labeld based on the folder,- and file names.
The buttons have to link to the files and folders so the user can navigate the folder structure and open a *.txt file and read it. Also the idea is that the buttons reflect the folder structure as it is in the assets folder.
The idea is that the user can easly retrieve info from the app and i can add info to the app trough *.txt files and adjust the structure just by adding/removing directories and files in the assets folder.
i am using android studio but like i already say'd: i am a beginner with programming and would like to know if this is even possible with android.
And if it is: could someone please tell me how i should start this project or link me to some example code on how this could be done?
Thanks in advance.
If i read your idea correctly, what you are trying to achieve is very much possible. I would start looking at the AssetManager class and I believe what you are looking for is the list() command which should give you what you need.
https://developer.android.com/reference/android/content/res/AssetManager.html
You can obtain the AssetManager from everywhere within your app through the Context object which you will find to be everywhere around. ;)
From there on you can build your hierarchy and open files.
There are some useful wizard projects in Android studio, which will basically setup a general structure of an Android App. I would recommend starting with a Single Activity application and move on from there.
It sounds like ListView is something that could be beneficial for you here. ListView allows you to dynamically create buttons, or whatever you need. ListView has the added advantage that you can use an XML file to inform the ListView of how to display the buttons, images or whatever you want to display for each element of the list. There are loads of videos demonstrating how to use ListView, but here is a link to its documentation: https://developer.android.com/guide/topics/ui/layout/listview.html
Also, if you'd like a structured way of learning how to develop apps, I'd recommend the Android courses on Udacity to help you out.
Best of luck!
I am new in react-native. I am trying to develop my first app in react-native. I want to know what is the correct project structure for developing react-native apps.
As of now, I have created component in root folder. I want to know what approach should I take for defining model, utils, webservice urls in what structure.
Does it has some kinda framework as like express for creating project structure in nodejs.
From my experience in building quite a large app using react-native. I have followed this approach and it scales pretty well for a team of 5+ people working on it .
App folder : : In this folder I keep all the files/folders related to app. Do not add anything in root folder. the less convoluted the root folder is the better for new person to get started.
uicomponents :
The uicomponents folder holds all the generic controls that app needs. eg : Dropdowns, sliders, buttons, checkboxed. You can avoid this if you are using a external lib.
components :
This folder holds folders for each section of screen. I call it modules for app. Each module is specific area of app, namely : HomePage, UserData, Settings so on so forth. This varies from genre of the app. My happens to be enterprise app, So I have folders for each module for an app.
Utils :
I am big fan of keeping utils at one place. Things like text formatters, Db handers, Oauth Handlers and so on.
Stores, Dispatchers :
Anything related to flux, redux can go in there.
In general the app has to be broken down in appropriate folders and files. One specific part of the app or module as I say has to have its own folder. All the files needed by him has to be in it. This makes it easy to be maintained and reasoned about.
Avoid duplicating code from beginning. Keep reusable things in Utils. All control related components (inputs, buttons, checkboxes) at one place.
Always keep styles at one place. Use constant variables for colors, this makes making changes very easy. The constant file holds colors.
I'm having a lot of doubts and after two days of searching I still haven't found a good answer for my problem.
I have an app's project that is already in the store and this project have lots of Activities, Fragments, Services, IntentServices, Layouts, and resources (images, strings, integers, colors, styles, raws, drawables, etc...).
Now, I need to implement a new app that is almost a copy of the first one where I need only to change the background, some resources (but almost 99% stay the same), and maybe in one or two fragments I'll need to change some code (implement different logic statements).
I decided and I think it's natural to convert the all project in an library project.
I did:
1º Create a new project called framework and configured as library. Copied all code and resources (with the exception of assets folder) from the original project to here.
2º In the original project I leave only the manifest, proguard file. I change the manifest and proguard file to reference the classes of the new library.
I tested the app to see if was still working and it was Ok. Until now I did only the separation.
Now, came the problem. I need to create a solution reusable,and scalar for the library that allows me to use it in different apps.
In my original project I created a subclass of Application class that I use for global variables.
Without any others ideas, I decided the following:
1º Convert my MyApplication class in an abstract class. Also, I create an interface ApplicationInterface with some methods like isBackgroundOverlayed() or getBackgroundResource() that I use in the fragments to change the backgrounds or any other logic from the originally defined.
2º In the App's project, I created a new Application class that extends the abstract class MyApplication and implements the interface ApplicationInterface and which is declared in the Application tag in the manifest file.
Conclusion: This all works and I was able to have two app's projects with different background and other images like logos and even change some code logic. An example is in the original App when the user press one certain button, the App shows a dialog choice. In the new app when the user press the button it execute one fragment (without choice).
My concerns: I don't feel this is the best solution for the problem or best practice or good "pattern".
Do you have any ideas?
Thank you in advance!
ps: Sorry if I haven't use this forum properly. I search for an answer but I didn't found any.
I think you have achieved what you wanted, but that was a lengthy and time consuming process. One more thing I would like to mention is you should not change library projects for different applications
As said on Android developers guide :
Library projects contain shareable Android source code and resources that you can reference in Android projects. This is useful when you have common code that you want to reuse.
you can read more from here
Also you have to figure out,which lib is doing which work in case you forget what changes you have made
I would suggest you to keep a separate copy of original project and then import it into new work space in Eclipse (by checking copy project into current work space so that you have a new copy of your project) and consider changing its package name to get a new project
you can refer ans on this link to see how to change package name`
I'm sure you can help such a newbie like I am.
I created a project in android and I want to use it as a model for next 10 and more apps, just changing the raw sources.
I mean I want to make some products i.e. 10 videocharts about norway, I make one project with the needed activity and resources so each app will differ only for the content value.
I will keep of course the same file name too if needed.
How can I save the project?
Cause I tried to make a new project from resource but I get an error on top of the tab saying Manifest is not present in the folder while manifest is actually there, and I cannot proceed further.
Thank you
ANgelo
This sounds like a place to use an Android library project.
My current project is getting awfully large. I have dozens of activities, adapters, fragments, layout xmls, and other resources.
In my (smaller) previous projects I organized stuff with a 1 package / 1 category style. So I had com.stuff.xy.adapter, com.stuff.xy.activity, and so on. Now these packages contain too many items, and I find myself wasting considerable amounts of time searching for a specific class in the package hierarchy.
I use Eclipse, and there are some shortcuts one can use (go to class definition e.g.), but those tend to be situational (I can't use that to quickly jump to a layout definiton xml).
Could you share some tips on organizing large scale projects efficiently? Or some plugins for this perhaps? (It might help for example if I could group together source files that deal with a specific application screen - adapters, layouts, activity and fragment code - so I can quickly open them)
EDIT: After many months developing large projects
First I tried to go with working sets with Eclipse. It didn't really cut it for me, my problem was that our single Android project was simply too big, containing many resources, classes, interfaces, etc. Messing around with working sets in the context of a single project just took too much time, I think that they're mainly useful to organize projects in a single workspace.
On the long run we separated our huge single project into many smaller android-library projects and a single "main application" project that depended on all these smaller ones. This way we could split the resources among these library projects (there were many layouts, values, styles that were only used in certain parts in the application) and code of course. I also created a Base library, that all other libraries depended upon, and contained resources and (base)classes that every part of the application needed.
For all my android projects I prefer to sort code in the following structure:
com.company.projectname is the package of the application.
Underlying packages:
model - all my business-objects
logic - services and objects implementing business logic
screens - all the activities of the project. If activities require adapters and so on, then each activity is placed in a separate package under screens package and the related stuff is placed to the same project.
tools - package with Utility class. SettingsUtil and so on.
In the root of the package I usually have Constants.java interface with constants.
In Eclipse, you can use Working Sets to filter your source/layout/resource files in the Project Explorer view. This is a bit more powerful than packages, since it operates on all files including layout and image assets, not just java source files.
For example, you could create a Home working set which contains HomeActivity.java, HomeAdapter.java, res/layout/home.xml, res/drawable/home_icon.png, etc.
Just another tip.
Use Ctrl-Shift-R to quickly open a resource (you get an autocomplete drop down) and Ctrl-Shift-T to quickly open a java class. The list will also auto-populate using the most recent opened files.
Maybe a tip: to quickly go to a declaration in Eclipse
Hold Ctrl while hovering over a class or method. After 1 sec you get a popup with open declaration / open implementation.
Very useful in large project.
For the rest i recommend just making it intuitive and sort all Activities in a package aswell as all calculations e.g.
for your concern "I can't use that to quickly jump to a layout definiton xml", you can click the name of the layout xml, then ctrl+shift+R will lead you to that definition page.