Error inflating class fragment Android Map v2

后端 未结 4 1584
忘掉有多难
忘掉有多难 2021-01-23 11:20

I know this is a duplicate question, but solutions from previous post doesn\'t worked for me. Thats why am asking this question.

I am tryi

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 11:31

    I have download your project from git and after checking i found that you have missed a line which is required to display map Fragment.

    Replace your main activity code with the following code:-

    public class MainActivity extends FragmentActivity {
    private GoogleMap map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();
    }
    

提交回复
热议问题