Android Studio and genymotion Android start from scratch-1

Source: Internet
Author: User

The life cycle of activity: I don't have a detailed record.
Understanding activity:
Activity components:

Setcontentview set the activity's view to show activity:

Here we comment out the Setcontentview code, and we can see that the interface inside the genymotion becomes blank.

Press F4 here

You can jump to the called R layout file.

Here we try to use our own defined layout file to display:


We define two buttons in the layout of our own definition:

The effect is like this:

We can experiment by calling our layout in mainactivity:

So here we can see the effect:

At the same time we can also be configured in the Androidmanifest file:

To start our custom activity:

?



Start a new activity for us to jump,



This is another aty.

In the main interface we call this code to set the listener event for the button.

  findviewbyid  (R.id.   butstartanotheractivity  ). Setonclicklistener ( Span style= "COLOR: #cc7832" >new view.onclicklistener () {
@Override
public void Onclick (View v) {
StartActivity (new intent (Mainactivity. This,anotheraty. Class }
}) ;
} /span>


So we move the button-pressing event to another Aty



You can see that we are successful and return to the original activity when the click returns.

To start a page:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com")));


Use this method to start a page (the default browser is called and automatically returns to the previous page when the page is closed):




Here's a successful jump back.
In the list of recent applications, we can see that we have called the default browser to implement this function.

So, to the end of this, I will continue to update the ~ new Blogger Master all progress together Oh, Sina Weibo: Hong Evil

?

Android Studio and genymotion Android start from scratch-1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.