Android Personal Finance Tools One: Project overview and implementation of the launch interface _android

Source: Internet
Author: User
Tags sqlite sqlite database

Start with this article to create an Android personal finance tool for everyone, and write down the entire development process to share with you.

General Introduction of the project

The main function of this Android personal Finance tool is to enter the various types of income and expenditure details in daily life, and to be able to count the monthly categories at the end of each month. The paper gives a report of the pie chart of income and expenditure and the column chart between the months.

The following diagram is a program flowchart:

Techniques that may be involved in a program:

1, multiple views of the switch, the transfer of parameters, the use of intent.

2, the embodiment of Grid details.

3, SQLite the data operation.

4. Self-painting view to performance statistics chart.

Write these first.

Implementation of the Start interface

The main function of the starting interface is to display a startup image and to initialize the system in the background.

If this is the first time to use this program, you need to initialize the program's SQLite database, build a library, build a table, initialization of the accounting data.

If not used for the first time, enter the registration revenue record interface.

Interface effect as shown:

The interface is simple, a imageview and a textview.

But how do I get 2 view vertically centered? When I started using linearlayout, I couldn't do the vertical and horizontal center, and then I used relativelayout to center horizontally.

The specific XML for the interface is as follows:


xml/html Code

<?xml version= "1.0" encoding= "Utf-8"?> <relativelayout "android:id=" 
xmlns: Android= "" 
android:layout_gravity= "Center_vertical|center_ Horizontal " 
android:layout_height=" wrap_content " 
android:layout_width=" wrap_content "> 
< ImageView android:id= "@+id/imageview01" 
android:src= "@drawable/logo3" android:layout_width= "Wrap_ 
Content " 
android:layout_height=" wrap_content "> 
<textview android:id=" @+id /textview01 " 
android:text=" @string/welcome " 
android:layout_below=" @id/imageview01 " 
android: Layout_width= "Wrap_content" 
android:layout_height= "wrap_content" > 
</ Relativelayout> 

I'm here to use a little trick, that is, after the initialization of the program, let the picture fade out, and then display the next interface.

At first I was going to use a timer to update the alpha value of the picture, and then the program threw an exception only the original thread created a view hierarchy can touch it.

This shows that the Android UI controls are thread-safe.

Here we need to open a thread to update the picture on the interface outside the main thread. You can use Imageview.invalidate.

The relevant code on how to open a separate thread update interface is as follows:

Java code

Send message update to main thread ImageView 
mhandler = new Handler () { 
@Override public 
void Handlemessage (msg) { 
Super.handlemessage (msg); 
Imageview.setalpha (Alpha); 
Imageview.invalidate (); 
New Thread (New Runnable () {public 
void run () { 
while (b < 2) { 
try { 
//delay 2 seconds, update once every 50 milliseconds imageview
   if (b = = 0) { 
b = 1; 
} else { 
thread.sleep (m); 
Updateapp (); 
} catch (Interruptedexception e) { 
e.printstacktrace ();}}} 
). Start (); 
The public void Updateapp () { 
alpha-= 5;//each reduction of Alpha 5 
if (Alpha <= 0) { 
b = 2; 
Intent in = new Intent (this, com.cola.ui.Frm_Addbills.class); 
StartActivity (in);//Start the next interface 
mhandler.sendmessage (Mhandler.obtainmessage ()); 

With this code, we can understand how Android updates the UI view.

In the next article, let's look at the use of SQLite. How to initialize the program.


Java Code

Package com.cola.ui; 
Import android.content.Intent; 
Import Android.os.Bundle; 
Import Android.os.Handler; 
Import Android.os.Message; 
Import Android.util.Log; 
Import android.view.KeyEvent; 
Import Android.widget.ImageView; 
Import Android.widget.TextView; 
 public class Colabox extends activity {private Handler Mhandler = new Handler (); 
 ImageView ImageView; 
 TextView TextView; 
 int alpha = 255; 
 int b = 0; 
 public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); 
 Setcontentview (R.layout.main); 
 ImageView = (ImageView) This.findviewbyid (R.ID.IMAGEVIEW01); 
 TextView = (TextView) This.findviewbyid (R.ID.TEXTVIEW01); 
 LOG.V ("Colabox", "colabox start ..."); 
 Imageview.setalpha (Alpha); 
  New Thread (New Runnable () {public void run () {Initapp ();//init program while (b < 2) {try {if (b = = 0) { 
  Thread.Sleep (2000); 
  b = 1; 
  else {thread.sleep (50); 
  } Updateapp (); catch (InterrupteDexception e) {e.printstacktrace (); 
 }}}). Start (); 
 Mhandler = new Handler () {@Override public void handlemessage (message msg) {super.handlemessage (msg); 
 Imageview.setalpha (Alpha); 
 Imageview.invalidate (); 
 public void Updateapp () {alpha-= 5; 
 if (Alpha <= 0) {b = 2; 
 Intent in = new Intent (this, com.cola.ui.Frm_Addbills.class); 
 StartActivity (in); 
 } mhandler.sendmessage (Mhandler.obtainmessage ()); 
 public void Initapp () {}}

Series of articles:

Android Personal Finance Tool Six: Show billing details below

Android Personal Finance tool five: show billing details

Android Personal Finance Tools Four: Add Bill page below

Android Personal Finance Tool Three: Add Bill page

Android Personal Finance Tools two: Use SQLite to implement initialization data at startup

Android Personal Finance Tools One: Project overview and implementation of the launch interface

The above is the development of simple Android application process, follow-up continue to add, thank you for your support!

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: 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.