我无法想象如何获得下面的条件方法& / Toast消息的Bundled Key。
我的学习经历将非常感谢任何帮助。日Thnx。
public class ListViewFragment extends ListFragment implements OnItemClickListener {
private final String KEY_ADPTR_ID = "KEY_ADPTR_ID";
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState):
Bundle args = this.getArguments();
args.getString(KEY_ADPTR_ID);
. . .
}
. . .
private void showData(String json) throws JSONException {
String adptrID = this.getBundle(KEY_ADPTR_ID);//<-HOW DO I ACCOMPLISH THIS CORRECTLY!!??
Toast.makeText(getActivity(), adptrID, Toast.LENGTH_SHORT).show();
if (adptrID == "3") {
. . .
}
}
答案 0 :(得分:2)
如果您在片段的参数中传递KEY_ADPTR_ID,那么您在onActivityCreated中所写的内容是正确的
Bundle args = this.getArguments();
String keyAdaptrId = args.getString(KEY_ADPTR_ID);