我使用兼容包,修订版4将片段添加到我的Gingerbread应用程序.没有记录任何错误,但片段不再显示在屏幕上(它在我开始清理它并添加方法之前一次就完成了!).底部片段有望封装我的导航方法,如"goHome"和"goCart",并放在所有屏幕上.
我尝试将元素添加到我的布局中,并收到了android.view的可怕的Classnotfound错误.我进一步使用这种方法.
我的日志显示已添加片段.这是碎片:
public class BottomFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View v = inflater.inflate(R.layout.bottom_nav, container, false);
Log.v("BottomFragment","onCreate after inflate");
/*
ImageView find_img = (ImageView)v.findViewById(R.id.bottom_find_image);
find_img.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.v("BottomFragment.OnClickListener"," with Find clicked");
findRegistry();
}
});
*/
// Inflate the layout for this fragment
return v;
Run Code Online (Sandbox Code Playgroud)
上面显示的日志消息.这是添加片段的活动:
public class StartActivity extends FragmentActivity {
public static Context appContext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.find_main);
appContext …Run Code Online (Sandbox Code Playgroud)