The background image displayed when a field in the gridview is clicked: Android: listselector = "@ drawable/choose_gridview"

Source: Internet
Author: User

<Gridview <br/> Android: Id = "@ + ID/gv_apps" <br/> Android: layout_height = "fill_parent" <br/> Android: layout_width = "fill_parent" <br/> Android: numcolumns = "3" <br/> Android: horizontalspacing = "10px" <br/> Android: verticalspacing = "10px" <br/> Android: listselector = "@ drawable/choose_gridview" <br/> Android: layout_margintop = "28px" <br/> Android: layout_marginbottom = "58px" <br/> Android: layout_marginleft = "5px" <br/> Android: layout_marginright = "5px" <br/> </gridview>

The background image displayed when a field in the gridview is clicked: Android: listselector = "@ drawable/choose_gridview"

Android: numcolumns = "3" specifies the number of columns in each row of the gridview.

Android: horizontalspacing = "10px" horizontal interval between items in the gridview

Android: verticalspacing = "10px" vertical interval between items in the gridview

Remove title: requestwindowfeature (window. feature_no_title );

Full Screen Display:

1. Obtain the window object of the activity.

A) window win = getwindow ()

2. Set flag for this window object

A) win. setflags (windowmanager. layoutparams. flag_fullscreen,

Windowmanager. layoutparams. flag_fullscreen );

Set an adapter for a gridview

1. Prepare a layout file for each item in the gridview

2. Write a class to inherit the baseadapter

I. Explanation: A class inherits the baseadapter and needs to override several methods, including getcount (), getitem (), getitemid (), and getview ()

II. The most important methods are getcount and getview. Each item in the gridview is a view. This view is obtained through getview. When an item needs to be displayed, it will call the getview method in the adapter to obtain the view to be displayed. Therefore, if there are several items in the gridview, The getview method will be called several times to determine the number of items, which is obtained through the getcount method. Therefore, we should return the size of a list in getcount. In getview, an object at position in the list is obtained based on the parameter position. Layoutinflater is used to render the layout file into a view and assign a value to the control in the view.

3. About packageinfo

A) obtain information about all the installation programs in the system, including those installed by the user and those of the system itself:

I. Get packagemanager PM = getpackagemanager ()

Ii. List list = PM. getinstalledpackages (packagemanager. get_uninstalled_packages)

B) What information is encapsulated by packageinfo: packageinfo corresponds to a manifest file, and packageinfo encapsulates minifest files.

I. packagename

Ii. Version Information: versioncode and versionname

Iii. activity information in this package

Iv. Worker er information in this package

V. Information about providers in this package

VI. The service information in this package is encapsulated into xxxinfo, through which you can get the corresponding information

VII. You can also obtain applicationinfo.

1. Obtain the application name applicationinfo. loadlabel (getpackagemanager)

2. Obtain the drawable of the application)

Applicationinfo. loadicon (getpackagemanager)

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.