How Java Android implements the interface definition

Source: Internet
Author: User

============ Problem Description ============


The programming foundation is not very good ... I know there's an interface, but it doesn't work. To find a simple example ....

Normal Android programming time, such as button click event ... It is necessary to implement Onclicklistener interface ...
Private class Listent implements onclicklistener{@Overridepublic void OnClick (View v) {This interface will have a parameter V, which is the click event of the Control}}


I would like to follow the example above, the test class inside the definition of an interface See,see interface has a show (String info) .... The info inside this show method is the value of the member variable MSG in the class test.
PUBILC test{Private String msg;//is this class an abstract class? Can there be other functions implemented, such as Test_namepublic void Test_name () {log.i ("AAA", "Success");}  How do I get the interface?  public interface See {void showinfo (String info); }}


Then I use this class later, when the new class will implement this interface, according to the Showinfo info value to do other things
Private class Listent implements see{@Overridepublic void Showinfo (String info) {//Do other things}};//there's no way to use test_name in the class. Method?

============ Solution 1============


This is not an abstract class that allows implementations of other functions.

How Java Android implements the interface definition

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.