在安卓开发中,我需要将AppCompatActivity 转换fragment,请问该如何更改

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_page);

    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    loginBtn = findViewById(R.id.btnlogin);
    usernameText = findViewById(R.id.etuser);
    passwordText = findViewById(R.id.etpass);

            其中因为fragment 不支持setContentView和findViewById,请问这个该如何更改呢?

在fragment中可以通过如下方式进行操作:view = inflater.inflate(R.layout.login_page, null);
loginBtn = view.findViewById(R.id.btnlogin);
usernameText = view.findViewById(R.id.etuser);
passwordText = view.findViewById(R.id.etpass);