저는 실제로 Google Maps API를 사용하는 Android 앱을 프로그래밍하고 있습니다.펼치기 조각으로 된 레이아웃의 ViewGroup
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
map:mapType="normal"
map:uiCompass="false"
map:uiRotateGestures="true"
map:uiScrollGestures="true"
map:uiTiltGestures="true"
map:uiZoomControls="false"
map:uiZoomGestures="true" />
</LinearLayout>
그리고 조각에 asynchronically지도를로드
레이아웃 activity_main.xml은 다음과 같습니다. 나는 activity_main보기 팽창 할 때 :
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup mainView = (ViewGroup) inflater.inflate(R.layout.activity_main, null);
앱 충돌 및 반환 오류 :
내가 그것을 어떻게
01-15 19:25:16.045: E/AndroidRuntime(21115): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
을 를 해결할 수
?
mainView.setOnKeyListener(new OnKeyListener()
{
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_POWER)
{
//STUFF
}
}
});
는 당신의 도움을 주셔서 감사합니다 : D 네임 스페이스를 선언해야
휠을 재발견하려는 것 같습니다. 잘못된 길. 보기에 리스너를 추가해야합니까? 지도보기입니까? 커스텀 맵 조각을 만들고'onViewCreated (View, Bundle)'를 오버라이드한다. 매개 변수의 뷰는 맵 뷰입니다. 또한 자신이하는 일을 알지 못하는 이상 애플리케이션 컨텍스트에서 인플레이터를 사용하지 마십시오. –
답변에 다른 코드를 게시했습니다. 내 문제가 지금 무엇인지 확인하십시오. – Skazza
대신 다른 질문을 게시하는 것이 어떻습니까? –