美文网首页
definition

definition

作者: _robin | 来源:发表于2017-04-06 02:57 被阅读0次

this / getActivity()

this is a reference to the current class you are in. It can be an Activity,Fragment,Adapter,View, etc. And when you use it what you are doing is just passing a reference of the current object of that class.

Let's say you are working on a customView. Anywhere in the code of that view where you callthiswill be interpreted as the View itself, so the value of this changes depending on what class you are in.

The method getActivity() is defined only in the Fragment class and any other class extending Fragment and this method returns and Object of the type Activity.

On Android development is very common mixing those two because most of the applications code is in Activity classes, and calling this on an Activity class will return anActivityobject but as you can see they are not the same thing.


static, and final

static - only one copy of this reference. a property of a whole class. all objs in this class have access to this value

final - can't change, can't reassigne. is a constant.


Context

 is a abs class.

Context is a interface to global 全局 info of the app envi.

Interface is a group of abs methods.

Context allows access to:

app resources, class

call for:launching activity, broadcasting, receiving intent


Activity

Activity is a Java code that supports a screen or UI.

activity extends context.

activity is a context.


Abstract class and interface

public abstract class Animal {

// instance variable

private double weight;

// getter

public double getWeight() {

return weight;

}

//abs method, no codes in curly braces, no curly braces.

public abstract void eat();

}

abs method, undefined, no codes in curly braces, no curly braces,

instance variable - class variable, to be defined in sub class

interface only contains abs methods and static final variable. no constructor.

abs class contains instance variable, abs method and setter, getters.


Context

Context is a abs class.

Context is a interface to global 全局 info of the app envi.

Interface is a group of abs methods.

Context allows access to:

app resources, class

call for:launching activity, broadcasting, receiving intent


Return

这个问题的答案。这个返回值,可以等于给变量。

return to whoever calls the method


Intent

intent is a tool to send and receive msg between activities.

Intent intent = new Intent (Context packageContext, Class);

= ship a Parcel parcel (address, receiver)

class is the class the receive it and start, pkgcontext is the pkg where the receiver class can be found.

intent.putExtra(String, boolean)

extra key-value pair

string is the key, it contains the pkg domain, so it tells which pkg the sender activity is from.

so that if there are multiple senders actuivity from different apps, you can tell.

相关文章

  • Definition

    世间无意, 人心惶惶。 我们只是在互相伤害中, 缓慢生长。 你逐渐老去, 被我的话语刺伤。 嘴角的微笑, 又何时被...

  • definition

    this / getActivity() this is a reference to the current c...

  • definition

    Relief?…… Imprisonment? Sublimation? ……… Degeneration? Th...

  • Hello World of CAP App

    High Level Project Structure DB definition The definition...

  • Definition of Done

    Elaboration TBD Triage, and definition of the ticket On a...

  • The definition of better

    What you want to do is become better, the definition of b...

  • Industry  Definition

    Better and Better ...

  • Jump to Definition

    iOS11 Xcode 9 快速跳转到定义新姿势(Jump to Definition) 在Xcode9 不能和之...

  • Definition of selfishness

    edenmandom 職業生涯見聞趣事 There was a boss who told his employe...

  • Definition of love

    My Love is of a birth as rare As 'tis for object strange ...

网友评论

      本文标题:definition

      本文链接:https://www.haomeiwen.com/subject/fyjfattx.html