我目前有两个显示相机和图库的标签,例如Instagram app.tabs是片段。换句话说,我有一个viewpager和两个标签,并在标签片段,我想显示相机和画廊。我正在使用Mattise库来显示图库。
我的问题是在点击图库标签时显示图库。我当前的代码只是在我点击选择图片按钮时显示图库,当我点击图库标签时不显示。
此片段代码:
public class GalleryFragment extends Fragment {
private static final int REQUEST_CODE_CHOOSE = 1001;
private static final int RESULT_OK = 1002;
private View view;
private static final int reqCode = 1000;
public static GalleryFragment newInstance() {
GalleryFragment galleryFragment = new GalleryFragment();
return galleryFragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_gallery, container, false);
Matisse.from(GalleryFragment.this)
.choose(MimeType.allOf())
.countable(true)
.capture(false)
.captureStrategy(
new CaptureStrategy(true, "com.zhihu.matisse.sample.fileprovider"))
.maxSelectable(9)
.gridExpectedSize(
getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
.restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
.thumbnailScale(0.85f)
.imageEngine(new PicassoEngine())
.forResult(REQUEST_CODE_CHOOSE);
return view;
}
List<Uri> mSelected;
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
mSelected = Matisse.obtainResult(data);
Log.d("Matisse", "mSelected: " + mSelected);
}
}
}
此代码在我开始活动时显示图库,在点击图库标签时不显示...