package com.mugua.mgvideo.ui.common;
|
|
import android.os.Bundle;
|
import android.view.View;
|
|
import com.androidquery.AQuery;
|
import com.mugua.mgvideo.R;
|
import com.mugua.mgvideo.ui.BaseActivity;
|
|
import androidx.fragment.app.Fragment;
|
|
/**
|
* @author hxh
|
*/
|
public class CommonFragmentActivity extends BaseActivity {
|
|
|
@Override
|
protected void onCreate(Bundle arg0) {
|
super.onCreate(arg0);
|
setContentView(R.layout.activity_fragment);
|
String title = getIntent().getStringExtra("title");
|
String fragmentName = getIntent().getStringExtra("fragment");
|
|
AQuery mAquery = new AQuery(this);
|
mAquery.id(R.id.tv_title).text(title);
|
mAquery.id(R.id.tv_back).clicked(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
CommonFragmentActivity.this.finish();
|
}
|
});
|
|
Object fragment = null;
|
|
try {
|
Class clazz = Class.forName(fragmentName);
|
fragment = clazz.newInstance();
|
} catch (ClassNotFoundException e) {
|
e.printStackTrace();
|
} catch (IllegalAccessException e) {
|
e.printStackTrace();
|
} catch (InstantiationException e) {
|
e.printStackTrace();
|
}
|
if (fragment == null) {
|
return;
|
}
|
getSupportFragmentManager().beginTransaction().replace(R.id.fl_container, (Fragment) fragment).commitAllowingStateLoss();
|
}
|
}
|