Fragment怎么获取上下文?

例如此时我的Fragment是MineMain,我要获取其中一个Textview的id,可以:

mTitle1 = (TextView) MineMain.this.getActivity().findViewById(R.id.title1);
        mTitle1.setText("子核心管理");

或是:
final Context context = getActivity(); // looks like class field initialization

调用它直接像:MyFragmentClass.this.getActivity()

猜你喜欢

转载自blog.csdn.net/xiyangyang8110/article/details/53444293#comments_22504374
今日推荐