How can I connect my first screen with the second screen? - java

I am doing a small game, and at the first screen I have made a loading screen. After that I made a second screen. My problem that when I use the emulator it stays on the first screen which is the loading screen. What should I do to connect the first screen with the second?
NOTE: I am using Android Studio, and there is no buttons on the first screen.
If anyone could suggest a video tutorial for my problem, that would be awesome.
Thanks!

You need to have some trigger to call another activity, which in your case it might be when all your data is loaded. It could be something like this:
while(yourDataIsNotLoaded){
//your loading code inside here
}
Intent i = new Intent(getApplicationContext(), SecondActivity.class);
startActivity(i);
Considering that the second screen refers to SecondActivty.

Related

How to add another Screen inside a Fragment?

I'm new to Android programming, and I have some questions about what type of layout to use. I am developing an application and have already done a basic mock-up of the interaction I want the user to have.
Following some tutorials I managed to build an app with a Bottom Navigation Bar with 3 Fragments, each one with it's own view. But my goals is that when the user clicks a button on one of these Fragments, the application opens a new View on the same Fragment.
What is the best way to achieve this goal? I have attached an image of the mock-up I made below, hope it helps to clarify the question. Thank you in advance for taking the time to help me!
Link to the mock-up app
That's sounds like you want to start a new Activity.
Considering you have your fragments in CurrentActivity and you want to start InvokingActivity
On clicking button in CurrentActivity
onClickMethod(View v){
Intent intent = new Intent(CurrentActivity.this, InvokingActivity.class)
//put some extras if you like
startActivity(intent)
}
To get arrow in top left corner you need to update AndroidMainfest by adding to InvokingActivity
android:parentActivityName="CurrentActivity"

Android needing to send Intent when going back

this is my basic Sketch from the App I wrote, my Problem is that I Navigate between my Activities with (black arrows)
Intent intent = new Intent(this, someclass.class);
intent.putExtra("pos", pos);
startActivity(intent);
I am not using finish() to go back since I dont know wether it recreates my previous Activity, or if it just goes back without recreating. The main Problem here is that i need to pass pos around while i really only use it in FlashCardActivity but when I go back from, for example FlashcardChangeActivity it gets recreated which is good, since I want my elements of my RecyclerView to be actualized. I need the pos there since I call a Function in my Database which returns all the elements of a certain Folder which I will display than.
So how do I implement this more clean and better without having to drag around the pos.
(I would also have a UML Classdiagramm and my Code but i think the Picture i drew shows my Problem better)

Android Studio Swipe to Change Screen

Hello I am pretty new to Android Studio and I was looking but could not find out how to make app functionality so I can change the screen of my app by swiping any help of links or videos is greatly appreciated thanks!
You can check out ViewPager for that matter. It's used hand in hand with Fragments so I suggest, if you haven't, that you look into that too.
You'll need to make a recycleView list. Then you'll need to override the swipe handlers. Then you'll need to program the onSwipe() method to change the activity. Screens can be changed like so:
Intent myIntent = new Intent(v.getContext(), activity_main.class);
startActivity(myIntent);

How can I animate the opening of a secondary android activity? as on playstore news

Although I do know how to open another activity quite easily, using intent like the below:
Intent intent = new Intent(first.this, second.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra("selectedApp", ApplicationTitle.getText());
startActivity(intent);
When you use the android application "PlayStore News", when you select a news item rather than just being redirected to another activity. An animation occurs, where in the change between several small cards to one large occurs.
How can I accomplish this?
http://www.mysamplecode.com/2013/02/android-animation-switching-activity.html
There is a method
overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out);
You might want to check out https://developer.android.com/training/material/animations.html#Transitions
This explains how to define custom transitions between activities. In particular, you may be interested in shared element transitions. I'd be more specific, but its a fairly broad question
Check this sample code for animation while switching activities in android.
http://android-er.blogspot.in/2013/04/custom-animation-while-switching.html
http://www.mysamplecode.com/2013/02/android-animation-switching-activity.html

android eclipse: switch activity briefly shows previous activity screen

I am sure this is a basic question, but I'm developing an Android app using ADK and Eclipse.
When I try to transition Activities, the screen goes black and then briefly shows the previous activity screen before "flipping" to the new screen.
I don't have any custom transitions; I'm using the default.
I don't have much going on in my onCreate event (EXCEPT: I load my background image during onCreate! Could it be this?)
I really am looking at a very snappy transition, like a game like Words with Friends, where it appears to switch "instantly".
This depends on what phone you're using since different phones use different anamations. Try to call finish(); on every activity but your main one for example.. Or finish them all when the user switches activities

Categories

Resources