我现在正在编写教程,并且正在创建一个 Android 抽屉。
Java - 文件:
- MainActivity - NavigationDrawerFragment - AboutMeFragment - ContactInfoFragment - MyCompanyFragment
XML- 文件:
-activity_main -fragment_about_me -fragment_contact_info -fragment_my_company fragment_navigation_drawer - fragment_main
三个文件“AboutMeFragment、ContactInfoFragment、MyCompanyFragment 包含几乎相同的代码。
package blabla.app1;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class AboutMeFragment extends Fragment {
public static AboutMeFragment newInstance(){
AboutMeFragment fragment = new AboutMeFragment();
return fragment;
}
public AboutMeFragment(){}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflator.inflate(R.layout.fragment_about_me, container, false);
return rootView;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
((MainActivity) activity).onSectionAttached(1);
}
}
总之,我收到以下错误消息:1.“inflater”:无法解析符号充气机 2.“activity”:无法解析符号活动
谢谢