I have a button on an app. Upon clicking this button a new page should appear. The new page will have a list of videos pulled from somewhere online. My problem now:
1. I have the xml page I want to show, and the java class linked to it. I know how to make a button, set an on click listener and make the onClick() method. What do I put into that onClick() method?
2. Help me become more articulate in how I describe Android processes, give me material to read, links to Android documentation. Every time I go into read someting I am overwhelmed; so I've decided to break it down into discrete and manageable tasks. What can I read that will help me understand Android terminology and how applications are ment to function better?
Thank you,
Dave
put in your onClick() method this code:
Intent myIntent = new Intent(CurrentActivity.this, NextActivity.class);
CurrentActivity.this.startActivity(myIntent);
Don't forget to add your new activity in the AndroidManifest.xml:
<activity android:label="#string/app_name" android:name="NextActivity"/>
Related
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"
today I used Android Studio 1.4 for the first time. I decided to make a app that helps you find a movie to watch. Very basic. Main page with a buttom that sends you to a random movie with tittle, poster, imdb link and a buttom that sends you to a new random movie.
I got two problems.
The Mainpage buttom that sends the user to a random activity is not working. How can i code it so it will send the user to a random activity and preferred not the same one. Can you make it choose from 1 of 100 activities?
I only get a error when I try to bind the Imdb link to a button.
Well your asking a question which requires to do some looking around. You are asking some basic question, which you should be able to do.
Here is a little code that you can use
Button yourButton = (Button) findViewById(R.id.your_buttons_id);
yourButton.setOnClickListener(new OnClickListener(){
public void onClick(View v){
startActivity(new Intent(YourCurrentActivity.this, YourNewActivity.class));
}
});
I personally feel like you need to check some tuts online. This is the basic, if you struggle on this, then you would struggle a lot more else where.
Anyway, if you see findViewById(R.id.your_buttons_id); it lets the app know which button that was clicked.
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
I am new to android and was starting out by making a list of button.i want when each button click launch a same activity for them with diffrent resource such image and raw file
what is big deal here?
call same intent twice :)
refer how to start new activity here
You can the same activity/intent multiple times, just if you want the code in said activity to do something else you might want give it some extra information by using intent.putInt(<Key>, <Value>); and others
i am making an andriod application in which i need to go from one page to another on a button click. i have tried several things but nothing worked out.
Okay, so given these are different .java files, and each has it own Activity (so, different Activities) what you want to do is call an intent as such:
Intent myActivity = new Intent(class1.this,class2.class);
main.this.startActivity(myActivity);
If its in the same Activity, (which I dont recomend) just call setContentView() again