Application entry Main.java
:
public class Main extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.frame);
FragmentManager fm = this.getSupportFragmentManager();
Fragment fragment = fm.findFragmentById(R.id.fragment_container);
if (fragment == null) {
fragment = new com.note.note.Crime();
fm.beginTransaction()
.add(R.id.fragment_container , fragment)
.commit();
}
}
}
fragment
corresponding Crime.java (package: com.note.note)
File:
public class Crime extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater , ViewGroup container , Bundle state)
{
return inflater.inflate(R.layout.add , container , false);
}
}
error report after running:
No view found for id 0x7f07003e (com.note.note:id/fragment_container) for fragment Crime{5aacf1c -sharp0 id=0x7f07003e}
what is this? why? What can I do to correct this mistake?