Anyone has any idea how can i create a multitask video activity ot fragment like new youtube.
Can any body tell me the correct procedure to do this.
How do I achieve this type of feature with visual effect.
Everything happens in single activity, logic is separated by fragments.
This article:
http://flavienlaurent.com/blog/2013/08/28/each-navigation-drawer-hides-a-viewdraghelper/
Literally describes how to do this
What do you mean with multitask? With two activities one above the other?
If that's what you are asking for you can use SlidingMenu library, this allows you tu insert another layout on the same activity that can be hidden, a sliding menu.
SlidingMenu Lib
If you are asking for running a process outside UI thread you must use AsyncTask class. It provides an easy way of doing some work in a different thread.
AsyncTask Android
All what i need is ViewDragHelper Class.
Here is the documentation.enter link description here
Related
I have one activity and 2 fragments that never run simultaneously, A and B. Fragment A has a RecyclerView, and from fragment B I want to add views to that ReyclerView.
I know the documentation says two fragments should never communicate directly, but I'm not sure how far that goes and if my case is really considered communication.
Should I use a static method or implement an interface in the activity?
The best thing to do is use EventBus library. I have a demo app in which you can add items to RecyclerView from anywhere within the app using EventBus. Here is the link to the repo:
https://github.com/code-crusher/android-demos/tree/master/EventBusDemo
And if you want to understand how it works you can refer to my article:
https://medium.com/#code_crusher/eventbus-for-android
Hope it helps. Happy coding :)
My app has an album style feature that users can pick/take photos from device and load it in every page in this album.
Now the number of this album pages is up to user and should be unlimited. On the Other hand the codes that is being used in activities as you could imagine are exactly same. I have wrote code once and I just want to reuse this activity for each page of album. how should I achieve this?
Since there are thousands of apps that are provide this kind of functions I know there is a good way but i'm unable to find that. Just a trick or a link to a tutorial or even a small explanation is good enough.
Thanks in Advance.
You can create a next() method, and change every layout view in the page with this function, so that you are in same activity but only views are being changed.
One solution is to add the data to be displayed to the "extras" of the Intent which you use to start the activity.
Alternatively, you might want to look at using a Fragment instead of an Activity. You might also want to look at using ViewPager to be able to swipe through the fragments which display the album data.
When my program start I would like to do some settings before is really starting. Forexample choose the user, check the updates and so on. After these settings I would like to start the main program with the appropriate.
Which is the best way to do this?
You can run an AyncTask, or multiple if you need one for each check, in your onCreate() and show a ProgressDialog while the data is being fetched then cancel it in onPostExecute() and move on to the rest of the MainActivity depending on the data that is downloaded. If you need help getting started with AsyncTask you can see this SO answer on the basic structure.
If you use a ProgressDialog then the app will still start but the users will see something and know that data is loading so they won't feel like it is freezing or taking too long to load (or at least they will know why it isn't loaded right away).
AsyncTask Docs
Edit after comment
For what you said you want in your comment you can do this easily with an Activity that has a Dialog Theme. This will give you the functionality you need (a couple Buttons and store the values) but it will look like a little popup. You can't use an actual Dialog as they need an Activity, the same with any menus, AFAIK. Just create your Activity and make it the launcher and main using the Intent-filters then also add the following line to that Activity's tag in the manifest
android:theme="#android:style/Theme.Dialog"
This approach should give you what you need
There are numerous ways to do that.
First - your app is doing some heavy stuff and this may be freezing user interface. In that version do:
1. Create and activity on what you will override onCreate method and set some content with a spinner - so something will be alive and user will see that something is being done.
2. after you will compute all the things that your app need and may I suggest write it to some global variables override onStart method in what change layout to what suit you and give a user a great UI!
Second - you app is not heavy lifting here just throw everything into override of onStart method.
Handy material here for educating:
Just starting out developing some android apps. Coming from a web development background I'm wondering if the idea behind changing whats displayed on screen is similar to linking html files.
Say I had a button that once clicked would then display a completely new page, button gone and completely new content in its place. I had thought at first that this was done just by having conditional statements in the main activity class. But I don't see how this would work with the xml layout file.
So I have come to the conclusion that you have to define multiple xml files and switch between them using logic in the main class.
If this is correct whats the best way to go about this, and if not could some suggest how this is achieved normally?
Thanks.
I think it wise to follow the following tutorial: http://developer.android.com/training/basics/firstapp/index.html
Have you tried visiting Android developers' website?.The solution to your question can be obtained taking the Android training module in that website. You have said you want to go to a new page, you can use Activities here.
Let me explain you this in simple terms.
In Android for every page(Activity) you need to make a separate xml file. for example main_activity.xml.
And for each page(Activity) there is a java class. For ex MainActivity.java. This class may contain event handling and business logic part.
Now let's go to your question about switching between multiple pages.
Suppose you have 2 activities: MainActivity and SecondActivity.
Now in MainActivity you have a button then you set its onClick attribute to its event handling method. This can be done in xml file.
android:onClick="goToSecond"
Now in MainActivity.java you need to create a method which looks like this.
public void goToSecond(View v)
{
Intent i=new Intent(MainActivity.this,SecondActivity.class);
startActivity(i);
}
This is a code snippet for switching to second activity.
And I also agree with other answers that you should check out developers.android.com
Hope it helps.
There is no need to switch between the XML files for portrait and landscape mode. Android does that for you. If you are writing an app that uses both orientation, then you have to write separate layout files and keep them in layout(for portrait), layout-land(for landscape) folders. This is not at all necessary if your design looks same in both orientation.
I am a newbie in Android and currently I am designing an application where I have faced a big problem with changing views. I have 3 classes, each one for a different screen. I use a button to change pages but it does not seem to work. Every time I move to the next screen, the variables methods etc of the 2nd screen are located in a different class. Can you please show me the simplest way to do this? Thank you.
Place each screen in different Activity. Start respective activities according to button presses. To pass data between activities use Intent.
Activity Reference
Intent Reference
Simple Example for Activities and Intents