Android Learning Notes

Source: Internet
Author: User

< one > Set fullscreen

1. Insert Requestwindowfeature (Window.feature_no_title) before Setcontentview () in the Oncreat method;//Cancel title bar

GetWindow (). SetFlags (Windowmanager.layoutparams. Flag_fullscreen,windowmanager.layoutparams. Flag_fullscreen);//Cancel status bar

Note: This method flashes the status bar after activating the activity and then fullscreen

2, in manifest configuration: <activity android:theme= "@android: Style/theme.notitlebar.fullscreen"/> Only in the current Activity display full screen

<application android:theme= "@android: Style/theme.notitlebar.fullscreen"/> Configure full-screen display for the entire app

3,/** * Full Screen switch * *

public void Fullscreenchange () {

Sharedpreferences mpreferences = preferencemanager.getdefaultsharedpreferences (this);

Boolean fullscreen = Mpreferences.getboolean ("fullscreen", false);

Windowmanager.layoutparams attrs = GetWindow (). GetAttributes ();

System.out.println ("fullscreen value:" + fullscreen);

if (fullscreen) {

Attrs.flags &= (~windowmanager.layoutparams.flag_fullscreen);

GetWindow (). SetAttributes (Attrs);

Cancel Full Screen settings

GetWindow (). Clearflags (WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Mpreferences.edit (). Putboolean ("fullscreen", false). commit ();

} else {

Attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;

GetWindow (). SetAttributes (Attrs);

GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Mpreferences.edit (). Putboolean ("fullscreen", true). commit ();

}

}

< two >activity Jump pass value

With intent

Mainactivity

Intent in = new Intent (mainactivity.this,toactivity.class);
Bundle Bu = new bundle ();//vector of multiple values
Bu.putstring ("Name", str);
In.putextras (Bu);
StartActivity (in);

Toactivity

Bundle bundle = This.getintent (). Getextras ();

T2= (TextView) Findviewbyid (R.id.helloview);

    /* Get data from bundles, note types and key*/

String name = bundle.getstring ("name");

< three >tabhost

Tabhost tabhost = (tabhost) Findviewbyid (r.id.tabhost);
Tabhost.setup ();
Tabhost.addtab (Tabhost.newtabspec ("Tab1"). Setindicator ("Tab1"). SetContent (R.id.view1));
Tabhost.addtab (Tabhost.newtabspec ("TaB2"). Setindicator ("Tab2"). SetContent (R.ID.VIEW2));
Tabhost.addtab (Tabhost.newtabspec ("Tab3"). Setindicator ("Tab3"). SetContent (R.ID.VIEW3));

XML layout file

<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:id= "@+id/hometabs"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:orientation= "Vertical" >

<tabhost
Android:id= "@+id/tabhost"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content" >

<linearlayout
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:orientation= "Vertical" >

<framelayout
Android:id= "@android: Id/tabcontent"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content" >

<textview
Android:id= "@+id/view1"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:text= "First label"/>

<textview
android:id= "@+id/view2"
Android : layout_width= "fill_parent"
android:layout_height= "Fill_parent"
An droid:text= "Second label"/>

<textview
android:id= "@+id/view3"
Android : layout_width= "fill_parent"
android:layout_height= "Fill_parent"
An droid:text= "Third label"/>
</framelayout>

<relativelayout
An Droid:layout_width= "Match_parent"
android:layout_height= "match_parent" >
< Tabwidget
android:id= "@android: Id/tabs"
android:layout_width= "match_parent "
android:layout_height=" wrap_content "
android:layout_alignparentbottom=" t Rue "
</tabwidget>
</relativelayout>

</linearlayout
</tabhost>
</linearlayout>

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.