我需要帮助我搞不清楚这里有什么问题。我在一个switch case中有一个alertdialog,它应该在case2上显示:但是它在case1上显示:当我查找case2时:它仍然不会显示,下面是我的代码。
public static class PlaceholderFragment extends Fragment { private static final String SECTION_NUMBER = "section_number";
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
new MainActivity().bundle = savedInstanceState;
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
TextView textView = (TextView) ((LinearLayout) ((FrameLayout) v).getChildAt(0)).getChildAt(1);
switch(textView.getText().toString()){
case "TRADE":
Intent intent = new Intent(getActivity(),Brokers.class);
startActivity(intent);
break;
}
Snackbar.make(gridView,""+textView.getText().toString(), Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
switch(getArguments().getInt(ARG_SECTION_NUMBER)){
case 1:
return rootView;
case 2:
View view = inflater.inflate(R.layout.forum_home, container, false);
if(sp.getString(APPROVAL, "otl").equals("ail")){
}
else{
AlertDialog.Builder ab = new AlertDialog.Builder(this.getActivity());
ab.setTitle("Ac")
.setMessage("You need..");
AlertDialog alert = ab.create();
alert.show();
}
gridView.setVisibility(View.GONE);
return view;
}
1条答案
按热度按时间wswtfjt71#
看起来您使用常量节\u编号将值放入,但尝试使用arg \u节\u编号检索它。为什么不同?