[Development Diary of Android in a row from scratch] (14) -- Button control + Custom Button control, androidbutton

Source: Internet
Author: User

[Development Diary of Android in a row from scratch] (14) -- Button control + Custom Button control, androidbutton

I haven't seen you for a long time. It's the beginning of a new semester. Why do I feel so sad! Many things happened this week, and three days off on Holidays (not so leisurely For A Long Time ), the intern company was forced by the team lead to solve a background login problem. The result was to put the Android program aside and go to the PHP background framework. (people are just an Android intern, without such fun), the school teacher assigned a hibernate project and said I would give you a month to take a look, learning slowly (as a result, I posted a lot of hibernate video tutorials on the group, but I still learned it slowly, and the video is still very old, hibernate or version 3 ), I was also drunk when I met such a teacher. By the way, please refer to the hibernate tutorial, which is simple and easy to use. <(_)> 〈(__)〉

Now, let's go to the topic. What we need to do today is the button control. Buttons are the most common controls in window applications. They are also a common means of interaction between programs and users. The event processing triggered by the Button is called Evenr Handler. In Android, the Button event is controlled by the system's Button. OnClickListener. Next, let's take a look at how the most basic button control is implemented.

 

I. Basic Button controls

Ii. Custom buttons

Let's take a look.

 

This is a button that comes with a progress bar. It can display the progress of the asynchronous task and end the operation after completion. Let's see how it is implemented.

 

Iii. Conclusion

I wrote this button like an open-source project. Its address is https://github.com/torryharris/th-progressbutton.

I have added some URLs in the Code. These are all the materials I checked when I checked the entire open source code. If you do not understand them, you can also go to these addresses to see the materials.

To be honest, there are too many things to design custom controls, which are not suitable for learning at the entry level. However, there is a concept, which is also quite good.

In the next few minutes, I will introduce some concepts that I met today, such as animation, path, and canvas.

So today is the end ~

 

==========================================================

 

Author: cpacm
(Http://www.cnblogs.com/cpacm/p/3969840.html)

 


Wpf custom controls and Custom trigger events. For example, if a custom control has a button, see the detailed description.

// Define the event attribute public static readonly RoutedEvent ClickRoutedEvent = EventManager. registerRoutedEvent ("Click", RoutingStrategy. bubble, typeof (ClickEventHandler), typeof (ControlName); [Description ("when clicked")] public event ClickEventHandler Click {add {AddHandler (ClickRoutedEvent, value );} remove {RemoveHandler (ClickRoutedEvent, value) ;}// trigger the click event. register the Click Event void button_Click (object sender, RoutedEventArgs e) {e. routedEvent = ScrollChangedRoutedEvent; e. source = this; this. raiseEvent (e );}

In android development, The onClick attribute of the button control is incorrect.

Your name is wrong. It is inconsistent. You write on_Cilck in xml... On_Click is written in the code. So I cannot find it.

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.