Day two:
Task one: Set a fade effect on a screen
The effect of fading
Initanimation ();
private void Initanimation () {
TODO auto-generated method stubs
Alphaanimation alphaanimation = new Alphaanimation (0, 1);//Transparency
Alphaanimation.setduration (3000);//Set length
Rl_root.startanimation (alphaanimation);
}
private void Initui () {
TODO auto-generated method stubs
Tv_version_name = (TextView) Findviewbyid (r.id.tv_version_name);
Rl_root = (relativelayout) Findviewbyid (r.id.rl_root);
}
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Xmlns:tools= "Http://schemas.android.com/tools"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:background= "@drawable/LAUNCHER_BG"
Android:id= "@+id/rl_root"
Tools:context= ". Splashactivity ">
OK, configure the theme of the project
<!--application theme. -
<style name= "Apptheme" parent= "Appbasetheme" >
<!--all customizations that is not specific to a particular api-level can go. -
</style>
<!--<textview
android:text= "Feature List"
android:gravity= "Center"
Android:textsize= "20SP"
Android:textcolor= "#000"
Android:padding= "10DP"
Android:background= "#0f0"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"/>--
<style name= "TitleStyle" >
<item name= "Android:gravity" >center</item>
<item name= "Android:textsize" >20sp</item>
<item name= "Android:textcolor" > #000 </item>
<item name= "Android:padding" >10dp</item>
<item name= "Android:background" > #0f0 </item>
<item name= "Android:layout_width" >match_parent</item>
<item name= "Android:layout_height" >wrap_content</item>
</style>
<textview
style= "@style/titlestyle"
android:text= "Feature List"/>
A custom class that focuses on content for scrolling
Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.widget.TextView;
public class Focustextview extends TextView {
Use to create controls through Java code
Public Focustextview (Context context) {
Super (context);
}
Called by the system (with attribute + context environment constructs method XML to Java object)
Public Focustextview (context context, AttributeSet Attrs) {
Super (context, attrs);
}
Constructed by system call (with attribute + Context Environment construction method + layout file definition Style file construction method XML)
Public Focustextview (context context, AttributeSet attrs, int defstyle) {
Super (context, attrs, Defstyle);
}
This is the second method of overriding the method of getting focus, called by the system, when called by default to get focus, better than TextView
@Override
public Boolean isFocused () {
return true;
}
}
<com.example.moblesafe73.view.focustextview
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
Android:ellipsize= "Marquee"
android:marqueerepeatlimit= "Marquee_forever"
Android:padding= "5DP"
Android:singleline= "true"
Android:text= "Fall and Fall quietly, leave a little secret, ah ah ah ah ah oh ah ah ah oh ah ah ah ah ah oh yes oh oh oh oh
Android:textcolor= "#000" >
</com.example.moblesafe73.view.FocusTextView>
Start setting up nine grid
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical"
android:gravity= "Center"
>
<imageview
Android:id= "@+id/iv_icon"
android:background= "@drawable/ic_launcher"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"/>
<textview
Android:id= "@+id/tv_title"
android:text= "Module title"
Android:textsize= "18SP"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"/>
</LinearLayout>
<gridview
Android:id= "@+id/gv_home"
Android:numcolumns= "3"
Android:verticalspacing= "10DP"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent" >
</GridView>
Import android.app.Activity;
Import android.content.Intent;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.view.ViewGroup;
Import Android.widget.AdapterView;
Import Android.widget.AdapterView.OnItemClickListener;
Import Android.widget.BaseAdapter;
Import Android.widget.GridView;
Import Android.widget.ImageView;
Import Android.widget.TextView;
public class Homeactivity extends activity{
Private string[] mtitlestrs;
Private int[] Mdrawableids;
Private GridView Gv_home;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_home);
Initui ();
Methods for initializing data
InitData ();
}
private void InitData () {
Prepare data (Text (9 groups), picture (9 photos))
Mtitlestrs = new string[]{
"Mobile Burglar", "Communication Defender", "Software Management", "Process management", "traffic statistics", "Mobile antivirus", "Cache cleanup", "Advanced Tools", "Settings Center"
};
Mdrawableids = new int[]{
R.drawable.home_safe,r.drawable.home_callmsgsafe,
R.drawable.home_apps,r.drawable.home_taskmanager,
R.drawable.home_netmanager,r.drawable.home_trojan,
R.drawable.home_sysoptimize,r.drawable.home_tools,r.drawable.home_settings
};
Nine Gongge control set data adapter (equivalent to a ListView data adapter)
Gv_home.setadapter (New Myadapter ());
}
Class Myadapter extends baseadapter{
@Override
public int GetCount () {
Total number of entries number of text groups = = Picture Count
return mtitlestrs.length;
}
@Override
Public Object getItem (int position) {
return mtitlestrs[position];
}
@Override
public long getitemid (int position) {
return position;
}
@Override
Public View GetView (int position, View Convertview, ViewGroup parent) {
View view = View.inflate (Getapplicationcontext (), r.layout.gridview_item, NULL);
TextView Tv_title = (TextView) View.findviewbyid (r.id.tv_title);
ImageView Iv_icon = (ImageView) View.findviewbyid (R.id.iv_icon);
Tv_title.settext (Mtitlestrs[position]);
Iv_icon.setbackgroundresource (Mdrawableids[position]);
return view;
}
}
private void Initui () {
Gv_home = (GridView) Findviewbyid (r.id.gv_home);
}
}
Android Project review (II)