3 detailed design of the system
3.1 General idea of the design of the main interface of the system
Generally we make the Head menu bar is to improve the operability of the software, you can use a combination of Tabhost+radiogroup method to make this part. The bottom position of the menu bar is achieved by tabhost this layout, followed by the linearlayout linear layout to lay out the content. The internal tabs are implemented via Tabwiget.
First set up the Android project (my project is named: Schedulemanager), under the project under the Res/layout to create an empty XML file called Main, and then in this file follow the idea to add layout code.
The menu options for the main interface are built using Radiogroup, where the layout contains 4 RadioButton Radiogroup, while RadioButton is a radio button. In this case, only one RadioButton can be selected, and the first button is selected at the beginning of the default. The implementation of the RadioButton is in the setting of the internal text, and then the top of the button to add slices, the implementation of the code is as follows:
<radiobutton
android:text= "@string/main_date"
android:drawabletop= "@drawable/tab_date"
Android:id= "@+id/radio_button0"
Android:checked= "true"
style= "@style/main_tab_bottom"/>
As you can see from the above code, each tab style in the menu is called Main_tab_bottom on style to implement the style, while the main_tab_bottom background background value @drawable/btn_bg,btn_ BG is not a simple background image, but an XML file, through this file can be implemented when the menu tab switch Background switch effect, making the menu bar more beautiful, the code is used by the selector of Android, here is the constant condition to determine which item to use, It includes several property values, such as whether to get focus, whether to respond to events, or whether to click on three conditions. The code is implemented as follows:
<selector
Xmlns:android= "Http://schemas.android.com/apk/res/android" >
<itemandroid:state_focused= "true" android:state_enabled= "true" android:state_pressed= "false" android:drawable= "@drawable/btn_bg_s"/>
<itemandroid:state_enabled= "true" android:state_pressed= "true" android:drawable= "@drawable/btn_bg_s"/>
<itemandroid:state_enabled= "true" android:state_checked= "true" android:drawable= "@drawable/btn_bg_d"/>
</selector>
After the layout of the main page is finished, the src/ In the mainpage file under Com.manage.activity, the layout is called in OnCreate (the OnCreate method is used to initialize the activity instance object), so far the layout of the top menu bar has been basically completed, but now the contents are empty. So we need to add tab content to tabhost here, take the first tab as an example, first by intent way to create a new mdate, to achieve the page jump method, Then dynamically use the Tabhost to add the corresponding Tabspec values and individual properties by means of the AddTab method.
Finally, in addition to the Radiogroup selection operation function, here is the implementation of the function of the corresponding button through switch, in each case item through Tabhost.setcurrenttabbytag to give a specific value to the page to achieve the jump.
In the above ideas we are detailed as follows:
Figure 3-1 System Main interface
3.2 System Touch reaction and page jump general design idea
The default selection interface of the system main interface is below the header menu bar.
(1) The first is to create a layout file, the above part is the display section. Using a TextView class, the corresponding calendaractivity file is added to the function to add information such as the year of the head.
First you need to write a CalendarView class, which is for displaying a class that uses overloaded methods to define several different parameters of the CalendarView for different situations. Instantiate CalendarView in calendaractivity and use one of the methods in CalendarView.
CalendarView (This,getresources (), Jumpmonth,jumpyear,year_c,month_c,day_c), and then write the method to add header information.
The first is the layout of the head of this page, through the dynamic method to complete.
Then create a parameter textdate that can change the value of the StringBuffer type. In the append operation of this parameter. There is a conditional function of judgment, which is awakened by the value of Calv.getleapmonth (). After the completion of the interface using the SetText method to assign values to the interface.
Finally, some beautification of the interface, the same use of dynamic layout mode.
(2) The following is the completion of the main part display in the interface
Adds a way to dynamically add a layout file when the calendaractivity file initializes the instance object. I'll name this method Addgridview. In this method is also the first dynamic layout, because this is used in the GridView, the GridView is applied to a series of space organized into a two-dimensional grid display, so it is suitable for me to make the date interface in the establishment.
The same first is the creation of the dynamic layout, which can instantiate the GridView for the GridView parameter. Here you need to add the GridView control as Column 7, with a column width of 46. And also add the condition of judging the screen size, this need to add the corresponding function to get the screen size, if this is the 800*480 screen, the column width is set to 69. You then set the horizontal and vertical spacing, the value border, and the center setting.
In this method, you also need to add a Ontouch method, which is used to pass the touch event in the GridView back to Gesturedetector, for the following touch operation, namely:
Pass the touch event in the GridView back to Gesturedetector
@Override
Publicbooleanontouch (viewv,motioneventevent) {
ReturnCalendarActivity.this.gestureDetector.onTouchEvent (event);
}
});
After the layout is created, it is added with specific information on it. For the currently displayed page, there are several corresponding parameters for displaying or transmitting data. For example, at the beginning of a function string[]daynumber=newstring[49]; this is used as a sequence of tokens within the GridView control, for the judgment of the following conditional statements, and for the instantiation of some control names within the interface. Then is the dynamic setting of the property value on the page.
The next step is the display of the current information, which also requires a conditional function to determine whether the data is eligible, and also to determine whether the parameter position is within range.
Through the above steps basically completed the initial construction of the interface.
3.3 System entry and Word query module module
User information does not want other programs to include the user name, user password, do not need to click on the "registration", if the user did not enter the necessary fields, but will not prompt user input to complete the registration. The word query module realizes the user query Word function, it verifies that the user submits the word is authorized, if the word is empty, will prompt please enter the user name, if the word did not enter or enter the error, will enter the word is empty or the error, and according to the access permission to provide the corresponding business function for the user. Once entered the success, you can directly enter the system to query the word, which greatly facilitates the user's operation. The specific program operation is as follows:
Fig. 3-2-1 English search words and keep raw separately words
Figure 3-2-2 Chinese search words
Translation module for 3.4 words
For a good self-learning application software, you can be unfamiliar with the sentence translation, the specific effect is as follows:
Figure 3-3 Sentence translation module
3.5 New Words This module
In the new words in this module in the process of searching words saved words, in the module we can manage the new words, you can delete the new words and when you click on a new word can jump to query the interface, convenient two times query. Specific as follows.
Figure 3-4 New words This module
Problems encountered:
This error occurred while running eclipse: No Launcher activity found! The launch would only sync the application package on the device!
Workaround:
Add <category android:name= "Android.intent.category.LAUNCHER"/> in Androidmanifest.xml
Android Practice Project report (III)