我首先有一个底部导航,但默认情况下我称之为跟随。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_tab);
fragmentManager = getSupportFragmentManager();
fragment = new ListActivityFragment1();
final FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(R.id.main_container, fragment).commit();
Bellow是我的ListActivityFragment1代码。事实上,我编码Android Studio的默认代码。我已经做了大量的阅读,所有关于位图的参与,但在我的情况下没有导入位图等的东西。我只是开始使用工具栏。
public class ListActivityFragment1 extends Fragment {
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public ListActivityFragment1() {
// Required empty public constructor
}
// TODO: Rename and change types and number of parameters
public static ListActivityFragment1 newInstance(String param1, String param2) {
ListActivityFragment1 fragment = new ListActivityFragment1();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_list_activity_fragment1, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
这是我捕获的堆栈跟踪。
03-03 07:20:58.073 1702-1715/system_process E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 104)
03-03 07:20:58.076 1702-1715/system_process E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 104)
03-03 07:20:58.082 1978-1978/com.android.inputmethod.latin E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 88)
03-03 07:20:58.085 1978-1978/com.android.inputmethod.latin E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 92)
03-03 07:20:58.088 1978-1978/com.android.inputmethod.latin E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 88
附加logcat。
03-03 08:07:03.654 1350-1759/? W/WVCdm: BufferReader::Read<T> : Failure during parse: Not enough bytes (4)
03-03 08:07:03.654 1350-1759/? D/WVCdm: PrepareKeyRequest: nonce=4212486394
03-03 08:07:07.284 2706-3072/com.google.android.gms I/Ads: Parental control value is stale. Refreshing.
03-03 08:07:07.284 2706-3072/com.google.android.gms W/Ads: Play store is not installed or the service for parental controls is not available.
03-03 08:07:08.974 2706-2716/com.google.android.gms I/art: Background partial concurrent mark sweep GC freed 15028(1224KB) AllocSpace objects, 23(460KB) LOS objects, 33% free, 7MB/11MB, paused 239.759ms total 1.281s
03-03 08:07:10.983 2706-2716/com.google.android.gms I/art: Background partial concurrent mark sweep GC freed 28761(2MB) AllocSpace objects, 12(248KB) LOS objects, 29% free, 9MB/13MB, paused 251.178ms total 1.297s
03-03 08:07:12.978 2706-3130/com.google.android.gms I/Icing: updateResources: need to parse snt{com.google.android.gms}
03-03 08:07:13.302 1971-2520/com.google.android.gms.persistent E/NetworkScheduler.SR: Invalid parameter app
03-03 08:07:14.528 1971-2482/com.google.android.gms.persistent E/NetworkScheduler.SR: Invalid parameter app
03-03 08:07:14.786 2706-3120/com.google.android.gms I/Icing: updateResources: need to parse snt{com.google.android.gms}
03-03 08:07:14.943 2706-2716/com.google.android.gms I/art: Background partial concurrent mark sweep GC freed 25328(2MB) AllocSpace objects, 10(200KB) LOS objects, 29% free, 9MB/13MB, paused 123.931ms total 231.671ms
03-03 08:07:18.317 2706-3132/com.google.android.gms I/Icing: updateResources: need to parse snt{com.google.android.gms}
03-03 08:07:45.774 1350-1350/? W/WVCdm: BufferReader::Read<T> : Failure during parse: Not enough bytes (4)
03-03 08:07:45.774 1350-1350/? D/WVCdm: PrepareKeyRequest: nonce=358789497
像cricket这样的问题建议不要在Android Studio模板中使用Fragment,而是在将来构建我自己的模板。正如我为其他人所做的那样,我将遵循这一点。这就是为什么这与其他帖子不相似的原因。