0
這是我placeholderfragment取代片段onActivityResult
public static class PlaceholderFragment extends Fragment {
private static final String ARG_SECTION_NUMBER = "section_number";
public static int SectionNumber;
public static LayoutInflater Inflater;
public static ViewGroup Container;
public static Bundle SavedInstanceState;
public static PlaceholderFragment newInstance(int sectionNumber) {
SectionNumber = sectionNumber;
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public PlaceholderFragment()
{ }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Inflater = inflater;
Container = container;
SavedInstanceState = savedInstanceState;
View rootView = null;
switch (SectionNumber)
{
case 1:
rootView = inflater.inflate(R.layout.fragment_main, container, false);
break;
case 2:
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
break;
case 3:
rootView = inflater.inflate(R.layout.fragment_main, container, false);
marketActivity = new MarketActivity(context);
marketActivity.loadMarkets(rootView);
break;
case 4:
rootView = inflater.inflate(R.layout.fragment_main, container, false);
break;
}
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
((MainActivity) activity).onSectionAttached(
getArguments().getInt(ARG_SECTION_NUMBER));
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
Log.e("onActivityResult", "1");
if(requestCode == 0) {
if(resultCode == RESULT_OK) {
Log.e("onActivityResult", "3");
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
movementActivity = new MovementActivity(context);
movementActivity.setUp(contents);
Inflater.inflate(R.layout.fragment_movement, Container, false);
Log.e("onActivityResult", "2");
Log.i("xZing", "contents: "+contents+" format: "
+format);
// Handle successful scan
}
else if(resultCode == RESULT_CANCELED)
{ // Handle cancel
Log.i("xZing", "Cancelled");
}
}
}
}
面對我的是onActivityResult當resultCode
是RESULT_OK
我想替換Inflater.inflate(R.layout.fragment_movement, Container, false);
當前片段,我希望我做我的問題明確到u的問題,即時通訊真的很抱歉mybad英語
方法不覆蓋或在親活性onResultOK實現從一個超類的方法 – user3806961
代替onResultOK –