Personal application software development for Android applications (1)

Source: Internet
Author: User

Currently, I personally work on my own financial management software. I am a financial management specialist who has no fixed funding plan or financial management plan every month. As a result, I have read other financial management software, which makes me very complicated and complicated. I think if I want to make a financial management software, I must first be convenient and personalized, it is possible that I can record the opening status of the day with one click (whether to add the same financial records for the next day based on the financial records of the previous day ). In addition, do I need to collect statistics on fund opening every day? Not necessarily, I only need to record my expenses for the day, and I can edit the Fund opening situation for one day in this month, another feature is that I forgot to add financial management yesterday. I chose the date for financial management. Even if I forget it, I can add it back. Of course, as a management software, we do not need to remember that it is very accurate. Instead, we are not a scientist who wants to make accurate numerical statistics. We only record the approximate funding situation and, according to this plan, the cost of opening the fund this month exceeds our expectation. For example, I bought 10 steamed stuffed buns in the morning. The price of the steamed stuffed buns is 1 yuan, 20 steamed stuffed buns are eaten at noon, and 20 steamed stuffed buns are eaten at night (of course I have not always eaten steamed stuffed buns ), we can just blur financial management. Breakfast 10 yuan, lunch 20, dinner 20, whether there are items to buy, must live consumables (vegetables, oil, salt, soy sauce, vinegar, tea, etc ). Okay, don't deduct the sheller. I directly divide what I need into four major parts!

Financial management functions can be divided into four major parts based on the above requirements:

1. Today's accounting (record the daily activation of Life)

2. Calendar of this month (calendar distribution of this month)

3. This month's journal (the column chart of resource consumption points for this month)

4. Opening statistics (actual opening comparison of one month's estimated opening and software records)

With these four functions, I can see where I spent all my money this month. How should I handle financial management in the next month? I just need to know the number of resources in my heart. The software is dead, people are living. We have to live every day according to our own ideas and live every wonderful day.

Uidesign:

UI design, we mentioned Android Layout Edior Layout Resource Manager. According to the man-machine interface provided by GOOGLE, we can easily reference some sophisticated kit Widgets. I think the widgets are roughly the same as those in silverlight/flax, A button is a button that provides services for us by event.

First, we create a new project. We can see that after the project is created, we have automatically configured and introduced the necessary environment for Android development.

Of course, we also see the androidManifest. xml configuration file. The entry point of our program Program is main. xml. Let's design our interface.

Since I want to expand to public software in the future, I need to design a login page, but this page does not have the data function at the moment. However, we can still achieve the login effect. The design concept is of course the same as the traditional one. Before the design, let's briefly introduce the layout methods of android:

Different la s are also important to adapt to different screens. Android screens are commonly used in three types of screen sizes. Here I will say it is 160.

Desity = 160 resolution: 320px * 533px average is 3 points two resolutions status bar 25px 25px vertical screen 320px * 508px

1. tablelayout (in adaptability, the rows and columns in the same way as tabel in the web must be aligned)

2. Linear layout linearlayout (behavior line layout, Adaptive High)

3. Relativelayout)

4. Absolute layout: absolutelayout (set based on the absolute path coordinates defined directly, and layout_x/y to adapt to the screen size)

5. Framelayout

Let's talk about what the three directories of drawable-* are used for. they store the files with different icons in 3, hdpi: 72*72; mdpi: 48*48; ldpi: the size of 36*36 is set by yourself, and the image size in the path is also different, for example, what we see on the taskbar, the same principle is true for different sizes displayed on the application layout.

The next step is to design the UI. I implemented the layout in the method 2 (linearlayout, absolutelayout:

For specific implementation, refer to the code.

There are two forms: Mian. xml and mylist. xml.

 

 

The interface has been designed, and the next step is the login code. The option is Create Activty entry point Activityclass name during project initiation. Let's take a look at the specific content in androidManifest. xml.

 

Write the code in ZisousoftminiActivity:

Full-text code:

Package Zisou. soft. mini; import android. app. activity; import android. app. progressDialog; import android. content. intent; import android. OS. bundle; import android. OS. handler; import android. view. view; import android. widget. button; import android. widget. editText; import android. widget. toast; public class ZisousoftminiActivity extends Activity {/** Called when the activity is first created. * // @ Override public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // Call main. xml layout form setContentView (R. layout. main); // currently, username and password are not required. Wait for the SQLite data to be expanded. final String str_username = ""; final String str_pwd = ""; // control definition method findViewById final EditText Et_username = (EditText) findViewById (R. id. editText1); final EditText Et_pwd = (EditText) findViewById (R. id. editText2); Button bt_login = (Button) findViewById (R. id. button1); // use setOnClickListener to listen and register the OnClickListener time method bt_login.setOnClickListener (new Button. onClickListener () {public void onClick (View v) {if (str_username.equals (Et_username.getText (). toString (). trim () = true) {if (str_pwd.equals (Et_pwd.getText (). toString (). trim () = true) {final ProgressDialog progre= progressDialog. show (ZisousoftminiActivity. this, "logging in... "," Please wait. Logging in... "); final Handler handler = new Handler (); final Runnable callback = new Runnable () {public void run () {// callback processing progressDialog. dismiss (); // close the dialog window Intent intent = new Intent (ZisousoftminiActivity. this, mylist. class); // use Intent to create a window activity program startActivity (intent); // switch the window mylist }}; // declare a Thread and process the callback thread Thread = new Thread () {@ Override public void run () {try {Thread. sleep (5000);} catch (InterruptedException e) {e. printStackTrace ();} handler. post (callback) ;}}; thread. start ();} else {Toast. makeText (ZisousoftminiActivity. this, "Incorrect password", Toast. LENGTH_SHORT ). show () ;}} else {Toast. makeText (ZisousoftminiActivity. this, "User Name error", Toast. LENGTH_SHORT ). show ();}}});}}

The code shows the setContentView (R. layout. main); open the Activity form of the program entry point, use setOnClickListener to listen and register the OnClickListener time method, so that we can write the specific method after clicking the button. The android sdk for the ProgressDialog class session window class is declared to provide me with five types: popup1_sw, Dialog, AlertDialog, ProgressDialog, and Toast.

ProgressDialog usage:

Final ProgressDialog progressDialog = ProgressDialog. show (ZisousoftminiActivity. this, "logging in... "," Please wait. Logging in... "); final Handler handler = new Handler (); final Runnable callback = new Runnable () {public void run () {progressDialog. dismiss (); Intent intent = new Intent (ZisousoftminiActivity. this, mylist. class); startActivity (intent) ;}}; Thread thread = new Thread () {@ Override public void run () {try {Thread. sleep (5000);} catch (InterruptedException e) {e. printStackTrace ();} handler. post (callback) ;}}; thread. start ();
Toast usage:

Note that ZisousoftminiActivity. this indicates switching between the current Activity and


Toast. makeText (ZisousoftminiActivity. this, "content prompted", Toast. LENGTH_SHORT). show ();
Intent is an important control class in android Activity. One is processing Action and the other is processing data to act on.

Write the code in ZisousoftminiActivity:

Package Zisou. soft. mini; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. view; import android. widget. adapterView; import android. widget. arrayAdapter; import android. widget. listView; import android. widget. adapterView. onItemClickListener; public class mylist extends Activity {private Object [] actobj = {"Personal Financial Management", myrmbmanage. class, "personal log", myrizi. class, }; Public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. mylist); // create an array CharSequence [] list = new CharSequence [actobj. length/2]; // serialized list for (int I = 0; I <list. length; I ++) {list [I] = (String) actobj [I * 2];} // BindListView extracts the array and binds the Text content value ArrayAdapter <CharSequence> adp = new ArrayAdapter <CharSequence> (mylist. this, android. r. layout. simple_li St_item_1, list); ListView lv = (ListView) findViewById (R. id. listView01); lv. setAdapter (adp); // setOnItemClickListener sets the OnItemClickListener event lv for each Itme. setOnItemClickListener (new OnItemClickListener () {public void onItemClick (AdapterView <?> Parent, View view, int position, long id) {// create a List action Intent intent = new Intent (mylist. this, (Class <?>) Actobj [position * 2 + 1]); startActivity (intent );}});}}

After the program is completed, run it to see if it is the desired function:

 

 

Well, it seems that the general uidesign work is in place. I still feel very good. I will continue to work hard in the next part to write the UI and function instructions in personal financial management!

We hope to work with you to learn about Android development and related application development. I will use a design pattern to write this program later. It is mainly used for database access class libraries.

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.