I am a new developer in Android. Currently I have started working on an app. I dont have any colleagues in Android so for my doubts and queries I am depended only on Stack overflow.
In my app I have placed three Edit boxes as follows with an ok button at last
FirstName:_____________
LastName:______________
DOB:___________________
When the user enters all data above and clicks the OK button at last, I am going to do the following process
Store the datas in a database
Send it to a particular URL
the data send to the URL will be get saved there
i just want to know how to implement this. What concept to be used.....
The actions, views and activies in Android are the baked in way of working with the Android UI and are an implementation of a model-view-viewmodel pattern, which is structurally similar (in the same family as) model view controller.
To the best of my knoweledge, there is no way to break out of this model. It can probably be done, but you would likely lose all the benefit that the existing model has, and have to rewrite your own UI layer to make it work.
You can find MVC in the followings:
You define your user interface in various XML files by resolution/hardware etc.
You define your resources in various XML files by locale etc.
You store data in SQLite or your custom data in /assets/ folder, read more about resources and assets
You extend clases like ListActivity, TabActivity and make use of the XML file by inflaters
You can create as many classes as you wish for your model, and have your own packages, that will act as a structure
A lot of Utils have been already written for you. DatabaseUtils, Html,
There is no single MVC Pattern you could obey to. MVC just states more or less that you don't should mingle data and view, so that e.g. views are responsible for holding data or classes which are processing data are directly affecting the view.
But nevertheless, the way Android deals with classes and resources, you're sometimes even forced to follow the MVC pattern. More complicated in my oppinion are the activites which are responsible sometimes for the view but nevertheless act as an controller in the same time.
If you define your views and layouts in the xml files, load your resources from the res folder, and if you avoid more or less to mingle this things in your code, then your anyway following a MVC pattern.
Google has tutorials for doing simple forms and taking actions when buttons are pressed. You should start there.
Next try the URL thing and next try the save data thing. If you follow the form tutorial you'll know where put code to execute when button is pressed (read the data tutorial).
If you follow others tutorials (to navigate) you'll know how to redirect to a URL (I would read "intents" but I'm not pretty sure, I'm not very prepared on Android). I guess that you should only "redirect to http://" and the system will decide (or ask the user) to open it in a browser or something diferent (like the youtube app). If you want to control the window navigation read this (but I don't recommend it).
But the bottom line is: read the tutorials and try things until you feel that you grasp the philosophy of the technology. Then search for specific things link redirecting, saving data, or taking a special action.
Related
I plan to build a simple website that takes data from a websites API and puts it into charts that are listed on my website. Here is what I am trying to do:
Take data from the API listed on localbitcoins.com
https://localbitcoins.com/api-docs/
Code a program that parses this data as I see fit.
Create a graphical layout that displays the data.
Post the graphs on a website that I have created, ideally to update in real-time.
I don't know where to begin.
I am not asking for some one to hold my hand through it all, but more so to give me some pointers on where to start, what resources are there that I can look at, and so on.
My instinct tells that that I need to tackle API and coding part first. Can someone point me to a resource that could take me through this? Should I stick with Java or should I use another language for this?
Wondering if anyone knows of a way to insert annotations programmatically using YouTube's Data API. It's entirely possible to access functions like upload, meta-data, etc. I don't see anything annotations however.
https://developers.google.com/youtube/v3/guides/uploading_a_video
Basically I'm trying to upload a video that has a different annotation on every frame (that points to a corresponding frame elsewhere in the video) — obviously the GUI YouTube provides would make that incredibly time consuming.
Here's an real example of the sort of functionality I'm after:
https://www.youtube.com/watch?v=VNRMSKSZY04
Any ideas welcome so long as they sit natively within the YouTube environment.
Many thanks.
Unfortunately you can not do it using the API. One way would be a browser Plugin to do this using the annotations-page...
By multipage I mean separate HTML files, say index.html, admin.html etc.
Now one solution to achieve this is to have this in the EntryPoint class:
if (!Window.Location.getPath().toLowerCase().endsWith("myhtmlpage.html") {
return;
}
The thing I want to understand deeply here is what is my GWT app have the main app, admin app, etc. The tendency of the app nocache.js file will get bigger, thus longer to load.
The question would be, does the code above prevent other parts of the compiled GWT app to load unnecessary parts of the app, say athe code for the Index EntryPoint or the Admin EntryPoint are loaded separately?
No, your if/return statement would not prevent any unnecessary javascript code to load.
The standard way to partition the UI javascript code is through code splitting.
The standard way to emulate multiple pages is by managing history & hyperlinks. Basically use tokens to manage your app states with hash code at the end of url -- e.g., #home, #admin.
A pattern I like is a combination of the above two. For a page that does not need to load initially, I hide it behind a GWT.runAsync code-splitting call to server with a distinct history token. For pages for which I want to dynamically control the content on the server side without having to recompile the javascript, I create a server call I fully control that returns html displayed on the browser through GWT HTMLPanel -- of course no need to recompile as long as the html structure and corresponding HTMLPanel code do not change. A side advantage of the latter is that you may control your server side logging to track page load statistics.
Finally, you may want to read up on GWT Activities & Places, from what I read a standard for dealing with history & such.
Right Patrick,
In addition, there is no way to use the code splitting method for js libraries that are not in your project (not GWT). So splitting pages is right to avoid js libraries you use for your admin code but you don't use in your front office, that's ok if you include the js in the page and you don't inject it through GWT. Otherwise it's your responsibility to split the code (have a common package that is available to all, but individual loads per 'page')
In theory, they say, the good split point is an activity (but I'm not convinced, since I have many activities in my pages, and loading each script alone could be bad for performance, so it's a per case analysis), you can see all what is included in your split in the compiler report
Take the time to look this video, it will save you a lot of troubles
https://www.youtube.com/watch?v=0F5zc1UAt2Y
No tutorial presents a concrete example of how an internationalization plug-in fragment is created an used. I need translations to the plugin.xml's and source code files. Trying to wrap my head around where the translations go, and where the i18n facade goes.
1. How does that fragment apply to an multi-plugin enterprise application, and more importantly, how do all those plugins externalize their strings inside appropriate folders in the fragment?
2. What about external JARs? How does the mechanism provide translation support for external resources?
3. With the risk of being a long-shot, would it be possible to provide independent translation of a view or perspective? Not necessarily at runtime, because I know bundles can't be dynamically switched.
There is some help available, this article lists the process. It's based on Eclipse 2.0 (!) but the basic ideas are still correct.
An even better article is this tutorial by Vogella
For each plugin you need to translate, you will create one plugin fragment. The fragment is associated to one host plugin, so you need several fragments. Each fragment can contain several languages though. The languages are separated by the folder structure as described in Step 5 in the first article
I am guessing you are referring to non-eclipse Java jars that you have made yourself, yes? If so, that is a completly different process, best suited for a separate question with the Java tag. Oracle has a guide that may help. But keep in mind that you only need to translate the content that the user is exposed to. So a refactor to keep all user visible strings to the Eclipse plugins might be a good idea.
Are you referring to the name of the view/perspective? If so, yes. You can translate the information you give in your plugin.xml aswell. See Vogellas article, chapter 3
Edit:
At nr.3 I was referring to choosing which View to translate (e.g. via a view menu), then restart the app, then only the said view should translate
Well.. I think of a way that would work in theory, but I'm not sure its the best alternative.
So translatation is based on locale. And given the locale a certain translation is chosen. If no appropriate translation exists, a default will be selected.
So if your View menu were to change the locale of the application to, say "us-en-v1", and you only had one view which had a translation for the locale "us-en-v1", that would mean that particular view would be translated, but the rest of the application would use a default (could be that they default back to the closest translation, dont remember exactly).
Then for each view you would create a new translation and use a unique locale for each.
That should work, but it abuses the way translations are supposed to work, so it could lead to issues.
I've done something similar at one time, one app was used in the same language but different customers had different vocabulary. So we used the i18n to make the application use the right terms by defining our own locales.
We are using http://babel.eclipse.org/babel/ to let people translate existing ressources. The build process adds the required language fragments to the artefact. Each plug-in defines its own Messages.properties / Messages.java file.
I guess, you can't do much about external jars.
For instance:
public final class MyMessages {
// a string member as you reference it later in the code
public static String login_window_user_label;
// static initializer which initalizes the fields in this class
static {
NLS.initializeMessages("mymessages", MyMessages.class);
}
}
And (usually in the same package) you have a properties file, in this case,
mymessages.properties
which includes the string:
login_window_user_label = Enter username to login to {0}
And within the code you do:
String userNameLabel = NLS.bind(MyMessages.login_window_user_label, Environment.getName());
Thats how we make our bundles "translatable". The build generates the language fragments and the babel server instance allows the translation.
I'm working on learning JSP and the Play framework, and I understand that it runs on Scala and renders views based on templates, but what if I just want to use plain HTML rather than scala templates?
The situation I'm in is that I'm designing the site to match a visual template, so I'm using Dreamweaver to build the html files. I really like Play framework though, so I'd like to continue using it. So, what are my options here?
I don't get. Play's views are not just nice html files, of course you can (or even should) use your favorite tools for design part, anyway you have to also learn how to include a dynamic parts in it.
Of course you can use DreamWeaver for that task as it has feature for editing source code. But I can ensure you from my own experience, that there are better tools for every-day work with Play's views than DW.
You can also use plain HTML in your /public folder however in this scenario you won't be able to make it dynamic, so it has no sense, as you can create the pages without any framework - just using static files created with DW.
In general words: you need to verify your needs, cause from your question I read: "I like Play framework, anyway I don't want to use it for its job..."
After-comments edit:
You don't have to make views dynamic. If you won't pass any arguments into the view and will put there pure HTML it will be 'relatively cheap' way for displaying static pages as well. Just you need to remeber to leave first line of the file empty. So you don't need to use File index = new File... instead just put your bare HTML code into ie: app/views/staticContact.scala.html and then use an action:
public static Result staticContact(){
return ok(views.html.staticContact.render());
}
On the quite other hand, last time I was wondering if it wasn't better to put HTML code of the static pages into the DB, in such case you could create an editing page, where you could change HTML without redeploying the application. All what you will need it was just fetching HTML from DB and displaying it in one generic view. For better performance you can use included Cache implementation.
GET / controllers.Assets.at(path="/public/html", file="index.html")
This is working for play 2.0.1 for /public/html/index.html file