[Android] Mobile defender welcome details and main interface

Source: Internet
Author: User

details of the splash interface

CTRL + O Search

In the title, the dialog is removed, a bit ugly, now there is a new version of the dialog box and do not display the title

remove the topic from the activity node in the manifest file

Go to the application node's style settings file and add a sentence

<item name= "Android:windownotitle" >true</item>

Set point return and Blank Place dialog box does not disappear

Call the alertdialog.builer object's setcancelable (false)to force the upgrade

or set the cancellation listener

The difference between the two contexts

When the dialog box is displayed, if you use getapplicationcontext () to get the context, an error occurs

Badtokenexception

dialog box is part of Activity

The dialog is attached to the activity , and theactivity is a subclass of the Context .

There must be some subclass of Father's class.

Subclasses have parent classes that do not necessarily have

Xxxactivity.this shorter life cycle, consistent with activity , with a little more

Getapplicationcontext () a little longer life cycle, consistent with application

The main interface of the application

Nine Gongge layout, use <GridView/> layout

GridView and ListView are two brothers, set three columns, android:numcolumns="3"

Set internal entry vertical distance,android.verticalspacing="10DP"

Get GridView Object

Call the Setadapter (adapter) Object of the GridView object , Parameter:adapter Object

Adapter is an interface that uses an inner class to inherit the baseadapter class to define

Define text data, static string[] names array,{"mobile phone anti-theft", "Communication Defender"}

Define picture data, static int[] icons array,{r.drawable.xxx,xxxxxxx}

Create an inner class Myadapter inherit baseadapter

Override GetCount (), method,return names length Property

Override the GetView () method,

Define a layout file, each item in the list, above is a picture, the following is the text

Call view.inflate (), Parameter: Context, resource,null

Call the Findviewbyid () method of the View object to find the inner control, set the text and the picture

Call the ImageView object's setimageresource (), parameter:icons[position]

Code:

 PackageCom.qingguow.mobilesafe;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.ViewGroup;ImportAndroid.widget.BaseAdapter;ImportAndroid.widget.GridView;ImportAndroid.widget.ImageView;ImportAndroid.widget.TextView; Public classHomeactivityextendsActivity {PrivateGridView gv_home_list; PrivateMyadapter Madapter; Private StaticString[] Names={        "Mobile phone anti-theft", "Communication Defender", "Software Butler",        "Process Management", "traffic statistics", "mobile antivirus",        "Cache cleanup", "Advanced Tools", "Settings Center"    }; Private Static int[] icons={R.drawable.safe,r.drawable.callmsgsafe,r.drawable.app, r.drawable.taskmanager,r.drawable.netmanager,r.    Drawable.trojan, r.drawable.sysoptimize,r.drawable.atools,r.drawable.settings}; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_home); Gv_home_list=(GridView) Findviewbyid (r.id.gv_home_list); Madapter=NewMyadapter ();    Gv_home_list.setadapter (Madapter); }    Private classMyadapterextendsbaseadapter{@Override Public intGetCount () {//TODO auto-generated Method Stub            returnnames.length; } @Override PublicObject GetItem (intarg0) {            //TODO auto-generated Method Stub            return NULL; } @Override Public LongGetitemid (intarg0) {            //TODO auto-generated Method Stub            return0; } @Override PublicView GetView (intarg0, View arg1, ViewGroup arg2) {View View=view.inflate (homeactivity. This, R.layout.list_home_item,NULL); TextView TV=(TextView) View.findviewbyid (r.id.tv_listhome_name);            Tv.settext (names[arg0]); ImageView IV=(ImageView) View.findviewbyid (R.id.iv_listhome_icon);            Iv.setimageresource (icons[arg0]); returnview; }}}

Activity_home.xml

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >    <TextViewAndroid:layout_width= "Match_parent"Android:layout_height= "40DP"Android:background= "#ccc"android:gravity= "Center"Android:text= "Feature List"android:textsize= "20SP" />    <GridViewAndroid:layout_margintop= "10DP"android:verticalspacing= "10DP"Android:id= "@+id/gv_home_list"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:numcolumns= "3" /></LinearLayout>

List_hone_item.xml

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:gravity= "Center"android:orientation= "vertical" >    <ImageViewAndroid:id= "@+id/iv_listhome_icon"Android:layout_width= "60DP"Android:layout_height= "60DP"android:src= "@drawable/safe"/>    <TextViewAndroid:id= "@+id/tv_listhome_name"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "mobile phone anti-theft"/></LinearLayout>

[Android] Mobile defender welcome details and main interface

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.