I want MyView
can share data with MyActivity
, so I need they can put data into Context
and get data from Context
, How to do that?
class MyView extends Button {
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
put data into context ...
get data from context ...
}
}
class MyActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xxx);
put data into context ...
get data from context ...
}
}
I know Activity
is a instance of Context
, and there is Context
in the View
's construtor.So I think when the Activity
started, At sometime, View
is trigger by event, so View
put some data in Context
, then at sometime, Activity
is trigger by event, so it cant get data from 'Context'. I want Context
to be a email box
which both View
and Activity
send and get emails from it. I think there is some methods like put(key, val)
and get(key)
in Context
but I not found.