Category Archives: Java

Android coding log

初始化一个Button

Button btn = (Button) findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /* action here*/
        }
});

setOnClickListener Method传递一个OnClickListener Interface Object. 从而Interface的OnClick方法被调用.

Kotlin的{} curly braces 可以是一个匿名函数Anonymous functions , shell 里面叫group command .

Java 子类不能override 父类没有定义的method.

The Activity class is a crucial component of an Android app, and the way activities are launched and put together is a fundamental part of the platform’s application model. Unlike programming paradigms in which apps are launched with a main() method, the Android system initiates code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle.

A Fragment represents a behavior or a portion of user interface in a FragmentActivity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a “sub activity” that you can reuse in different activities).