Android Project Call Butler (1)-----Interface Design

Source: Internet
Author: User
Tags dashed line transparent color

Because of the need, the recent days busy writing call Butler This small software, has been basically written almost, the basic functions have been realized, the rest of the following improvements, and the previous Notepad project has not been written in recent days, but certainly will be completed.

The basic function of call Butler, here is to intercept.

1. Add Black and white list

2. Select intercept mode

3. Enable intercept time period

4. Intercept switch

The main function is to select the interception by the user, and select the interception mode, this will start the background monitoring service, monitoring incoming calls, determine whether to hang up, and, the user can freely choose to intercept the time period, that is, in the time period to enable the monitoring service.

First look at the interface:

From the interface can also be seen, here is the main application of activitygroup and activity of the combination of use, in order to achieve the role of paging tags, similar to many software, such as QQ.

Directly on the code:

Main.xml This is activitygroup layout file, the figure of four pages is four activity, in the main layout file in the LinearLayout container

<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:orientation=" vertical "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "     ><relativelayout android:layout_height= "fill_parent" android:layout_width= "Fill_parent" ><GridView android:layout_height= "35DP" android:id= "@+id/gvtopbar" android:layout_alignparenttop= "true" android:layout_width = "Fill_parent" android:background= "@drawable/tabbar_bg" android:layout_centervertical= "true" ></gridview            > <imageview android:layout_width= "match_parent" android:layout_height= "Wrap_content" android:layout_below= "@id/gvtopbar" android:src= "@drawable/line"/><linearlayout android:i D= "@+id/container" android:layout_below= "@+id/gvtopbar" android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" android:orientation= "vertical" ></linearlayout></relativelAyout></linearlayout> 

Where the GridView is used to place the top distribution menu, ImageView is the dashed line in the graph, and the bottom linearlayout is the container for placing four pages.

The following is a layout file for four pages

Black and White list page layout file Activity_add.xml

<?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:id= "@+id/layout" > <listview android:id= "@+id/lv_show" android:layou T_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1" android:cacheCo Lorhint= "#FFF" > </ListView> <relativelayout android:id= "@+id/add_l Ayout "android:layout_width=" fill_parent "android:layout_height=" 50DP "Android:layout_alignparentbott Om= "true" android:visibility= "visible" android:background= "@drawable/tabbar_bg" > <imagev Iew android:layout_width= "match_parent" android:layout_height= "Wrap_content" android:src = "@drawable/line"/>      <button android:id= "@+id/btn_add" android:layout_width= "45DP" android:layout_height= "45DP"                          Android:layout_centerhorizontal= "true" android:background= "@drawable/add"/> </RelativeLayout> <relativelayout android:id= "@+id/delete_layout" Android:layout_wid Th= "Fill_parent" android:layout_height= "50DP" android:layout_alignparentbottom= "true" Android:visibil Ity= "Gone" android:background= "@drawable/tabbar_bg" > <imageview Android:layout_widt        H= "Match_parent" android:layout_height= "wrap_content" android:src= "@drawable/line"/> <button android:id= "@+id/btn_cancel" android:layout_width= "45DP" android:layou t_height= "45DP" android:background= "@drawable/backup"/> <textview A Ndroid:id= "@+id/tv_selecT "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:text= "Total selected item" android:layout_centerinparent= "true"/> <button android:id= "@+id/bt N_delete "android:layout_width=" 45DP "android:layout_height=" 45DP "android:background=" @d Rawable/delete "android:layout_alignparentright=" true "/> </relativelayout></linear Layout>

Block the recorded layout file Activity_callinfo.xml

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/                 Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "> <listview Android:id= "@+id/lv_show_callinfo" android:layout_width= "match_parent" android:layout_height= "Match_par Ent "android:layout_weight=" 1 "> </ListView> <relativelayout an Droid:id= "@+id/add_layout" android:layout_width= "fill_parent" android:layout_height= "50DP" Android:la Yout_alignparentbottom= "true" android:visibility= "visible" android:background= "@drawable/tabbar_bg" &       Gt <imageview android:layout_width= "match_parent" android:layout_height= "Wrap_content" a ndroid:src= "@drawable/line"/> <button android:id= "@+id/btn_delete_callinfo" Android:    Layout_width= "45DP"    android:layout_height= "45DP" android:layout_centerhorizontal= "true" android:background= "@drawable/delete "/> </RelativeLayout> </RelativeLayout>

Set the layout file for the page activity_setting.xml

<?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 " ><relativelayout android:layout_width= "match_parent" android:layout_height= "40DP" android:gravity= "cen ter "android:padding=" 8DP "android:layout_marginleft=" 20DP "android:layout_marginright=" 20DP "android:layout_m argintop= "30DP" android:background= "@drawable/setting_top" > <textview android:layout_width= "Wrap_co Ntent "android:layout_height=" wrap_content "android:text=" Turn on monitoring "android:textsize=" 15SP "/> <togglebutton android:id= "@+id/tb_switch" android:layout_width= "44DP" android:layout_height= "20DP" and roid:background= "@drawable/start_service_off" android:textoff= "android:texton=" "Android:layout_ali Gnparentright= "true"/></rElativelayout><relativelayout android:layout_width= "match_parent" android:layout_height= "40DP" Android:gra vity= "center" android:padding= "8DP" android:layout_marginleft= "20DP" android:layout_marginright= "20DP" Android : background= "@drawable/setting_middle" > <textview android:layout_width= "wrap_content" android:l ayout_height= "Wrap_content" android:text= "Whitelist Mode" android:textsize= "15SP"/><togglebutton Andro Id:id= "@+id/tb_whitelist" android:layout_width= "44DP" android:layout_height= "20DP" android:background= "@d Rawable/start_service_off "android:textoff=" "android:texton=" "android:layout_alignparentright=" true "/></relativelayout><relativelayout android:layout_width=" match_parent "android:layout_height=" 40DP "android:gravity=" center "android:padding=" 8DP "android:layout_marginleft=" 20DP "android:layout_marginright=" 20DP "Android:background= "@drawable/setting_middle" > <textview android:layout_width= "wrap_content" android:layout_he ight= "Wrap_content" android:text= "Enable time period" android:textsize= "15SP"/><togglebutton android:id= "@ +id/tb_time "android:layout_width=" 44DP "android:layout_height=" 20DP "android:background=" @drawable/start _service_off "android:textoff=" "android:texton=" "android:layout_alignparentright=" true "/>&lt ;/relativelayout><relativelayout android:id= "@+id/start_layout" android:layout_width= "Match_parent" Androi d:layout_height= "40DP" android:gravity= "center" android:padding= "8DP" android:layout_marginleft= "20DP" Android : layout_marginright= "20DP" android:background= "@drawable/setting_middle" ><textview android:id= "@+id/tv_sta          Rt_tip "android:layout_width=" wrap_content "android:layout_height=" wrap_content "android:text=" Start Time " Android:textsizE= "15SP" android:textcolor= "@android: Color/darker_gray"/><textview android:id= "@+id/tv_start_time" Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "2014-9-11 &        gt; " Android:textsize= "15SP" android:layout_alignparentright= "true" android:textcolor= "@android: Color/darker_gray "/></relativelayout><relativelayout android:id=" @+id/end_layout "android:layout_width=" Match_pa Rent "android:layout_height=" 40DP "android:gravity=" center "android:padding=" 8DP "android:layout_marginleft=" 2 0DP "android:layout_marginright=" 20DP "android:background=" @drawable/setting_under "><textview android:i D= "@+id/tv_end_tip" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android: text= "End Time" android:textsize= "15SP" android:textcolor= "@android: Color/darker_gray"/><textvie W Android: id= "@+id/tv_end_time" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Andro id:text= "2014-9-11 >" android:textsize= "15sp" android:layout_alignparentright= "true" Android:tex Tcolor= "@android: Color/darker_gray"/></relativelayout> </LinearLayout>

In the diagram, the surrounding lines in the page are actually used. 9.png images.

The layout file is above these, so the top page of the paging menu, and how to add four activity into the activitygroup.

1) The implementation of the top menu:

Since it is the GridView, of course to use the adapter, here is a custom baseadapter, as follows:

Package Com.example.callmanager;import Android.app.activity;import Android.content.context;import Android.content.sharedpreferences;import Android.view.gravity;import Android.view.view;import Android.view.viewgroup;import Android.widget.baseadapter;import Android.widget.gridview;import Android.widget.textview;public class Tabbaradapter extends Baseadapter {private Context mcontext; private textview[]    txtitems;private int selresid;         Public Tabbaradapter (Context c,int[] tabmenuid,int width,int height,int selresid) {mcontext = C;        This.selresid=selresid;        Txtitems=new Textview[tabmenuid.length];         for (int i=0;i<tabmenuid.length;i++) {Txtitems[i] = new TextView (mcontext); Txtitems[i].setlayoutparams (New Gridview.layoutparams (width, GridView.LayoutParams.WRAP_CONTENT));//        Set ImageView width height txtitems[i].setgravity (gravity.center);         Txtitems[i].setpadding (2, 5, 2, 5);        Txtitems[i].settext (Tabmenuid[i]); TxtitEms[i].settextsize (15);     }} public int GetCount () {return txtitems.length;     } public Object GetItem (int position) {return position;     } public long Getitemid (int position) {return position; }/** * Sets the effect selected */public void SetFocus (int index) {for (int i=0;i<txtitems.length;i+                        +) {if (I!=index) {txtitems[i].setbackgroundresource (0);//restore unselected style }} txtitems[index].setbackgroundresource (SELRESID);//Set the selected style} pub         LIC view GetView (int position, View Convertview, ViewGroup parent) {TextView TextView;                if (Convertview = = null) {TextView = txtitems[position];         } else {TextView = (TextView) Convertview;     } return TextView;  } }

The next step is to bind the custom adapter to the GridView, with the main code as follows (in Activitygroupdemo.java):

Public GridView Gvtopbar;
Private Tabbaradapter Topimgadapter;
/** top Menu **/<br abp= "804"/> int[] Topbar_menu_array = {r.string.black_list,r.string.white_list,<br abp= "805"/ > r.string.call_info,<br abp= "806"/> R.string.setting};
@Overridepublic void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.main); Gvtopbar = (GridView) This.findviewbyid (R.id.gvtopbar); Gvtopbar.setnumcolumns (topbar_menu_ Array.Length);//Set Gvtopbar.setselector (New Colordrawable (color.transparent) per row);//Transparent Color gvtopbar.setgravity When selected (gravity.center);//Position Center int width = This.getwindowmanager (). Getdefaultdisplay (). GetWidth ()/topbar_menu_ Array.length;topimgadapter = new Tabbaradapter (this, Topbar_menu_array, width, 48,r.drawable.menu_background); Gvtopbar.setadapter (topimgadapter);//settings menu Adapter}

In this way, the top menu function is complete, and when you click on a menu, there will be a selection effect, as shown here, the same is used in the. 9.png picture.

2) Add four activity into the Activitygroup, and click the corresponding distribution tag, enter the corresponding activity, four activity code not to say, is to load the layout file, mainly see the code in Activitygroup:

Public LinearLayout container;//container for loading sub activity
<pre class= "java" name= "code" abp= "813" >gvtopbar.setonitemclicklistener (New Itemclickevent ());// Item Click event Container = (linearlayout) Findviewbyid (r.id.container);    Switchactivity (0);//Open No. 0 page by default

class Itemclickevent implements Onitemclicklistener {@SuppressLint ("Newapi ") public void Onitemclick (adapterview<?> arg0, View arg1, int arg2,long arg3) {switchactivity (arg2);}} /** * Opens the specified activity * @param ID according to the ID gridview the ordinal of the selected item */void switchactivity (int id) {topimgadapter.setfocus (ID);// The selected item obtains the highlight Container.removeallviews ();//must first clear all viewintent intent =null;if in the container (id = = 0) Intent = new Intent ( Activitygroupdemo.this, Blacklistactivity.class), else if (id = = 1) Intent = new Intent (Activitygroupdemo.this, Whitelistactivity.class), else if (id = = 2) Intent = new Intent (activitygroupdemo.this, callinfo.class); else if (id = = 3) in Tent = new Intent (activitygroupdemo.this, Settingactivity.class); Intent.addflags (intent.flag_activity_clear_top); /activity to Viewwindow subactivity = Getlocalactivitymanager (). StartActivity ("subactivity", intent);// Container Add Viewcontainer.addview (Subactivity.getdecorview (), layoutparams.fill_parent, layoutparams.fill_parent);} 

In fact, is to use intent jump page, and add viiew into the window.

At this point, the interface Design section has been completed.







Android Project Call Butler (1)-----Interface Design

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.