您可以使用DialogFragment爲您的案件充氣佈局不是完美的答案。
要打開,你可以在你的網格項的點擊使用片段
FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
BaseDialogFragment Fragment = new BaseDialogFragment();
transaction.add(fragment, "loading");
Bundle args = new Bundle();
args.putString("your_data", yourdata);
// you can add as many string int or boolean. Explore it.
fragment.setArguments(args);
transaction.commitAllowingStateLoss();
public class BaseDialogFragment extends DialogFragment {
Typeface MR, MRR;
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().setCanceledOnTouchOutside(false);
}
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
WindowManager.LayoutParams windowParams = window.getAttributes();
windowParams.dimAmount = 0.50f;
window.setAttributes(windowParams);
}
public void onResume() {
super.onResume();
WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();
params.width = RelativeLayout.LayoutParams.MATCH_PARENT;
params.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.CENTER;
getDialog().getWindow().setAttributes(params);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.yourlayout, container, false);
// init your views here. or
get the data here from the Grid View
String your_data = getArguments().getString("your_data");
return v;
}
}
你可以使用dialogfragment對於這一點,你可以從網格視圖數據發送到片段,以便它可以顯示出相對內容 –