我已经厌倦了构建一个Android应用程序而且我遇到了问题。 我发布我的java代码,xml和错误。 有人可以教我为什么会这样,以及如何解决它?谢谢!
这就是我面临的问题......
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: FATAL EXCEPTION: main
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: Process: com.onemap.activities, PID: 21798
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.onemap.activities/com.onemap.activities.OneMap}: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.TextView
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:156)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.os.Looper.loop(Looper.java:157)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5872)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.TextView
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.createView(LayoutInflater.java:620)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at com.onemap.fragments.MainMenu.onCreateView(MainMenu.java:88)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.Fragment.performCreateView(Fragment.java:1965)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1047)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1237)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1339)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2295)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:314)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:31)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:79)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:375)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.Activity.setContentView(Activity.java:1997)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at com.onemap.activities.OneMap.onCreate(OneMap.java:58)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5312)
10-27 16:35:22.488 21798-21798/com.onemap.activities E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
这是我的java代码和xml
OneMap.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.onemap);
AppUtilities.init(this);
pomPref = getSharedPreferences(POM_PREF, MODE_PRIVATE);
pomEditor = pomPref.edit();
favDB = new FavouritesDBHandler(AppUtilities.getContext());
this.mMapView = (MapView) findViewById(R.id.mMapView);
this.mMapView.setOnStatusChangedListener(OneMapStatusListener.getInstance());
this.scrollView = (SlidingMenu) findViewById(R.id.mScrollView);
View mainContent = this.scrollView.getMainContent();
OnClickListener clickListener = getClickListener();
OnLongClickListener longClickListener = getLongClickListener();
mainContent.findViewById(R.id.mScreenToggle).setOnClickListener(clickListener);
JewelContainer jewelContainer = (JewelContainer) mainContent.findViewById(R.id.jewel_container);
jewelContainer.setOnClickListener(clickListener);
jewelContainer.setOnLongClickListener(longClickListener);
this.mMapView.setOnSingleTapListener(getSingleTapListener());
this.mMapView.setOnLongPressListener(getLongPressListener());
this.mMapView.setCalloutClickListener(getClickListener());
this.mMapView.getCallout().setMaxWidth(550);
}
MainMenu.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.menu_main, container, false);
ViewHolder viewHolder = new ViewHolder();
viewHolder.arrowUp = (ImageView) view.findViewById(R.id.iv_arrow_up);
viewHolder.arrowDown = (ImageView) view.findViewById(R.id.iv_arrow_down);
ListView menuList = (ListView) view.findViewById(R.id.menu_list);
menuList.setOnItemClickListener(this);
menuList.setOnScrollListener(this);
menuList.setTag(viewHolder);
MenuItem[] arrayMenuItem = new MenuItem[5];
arrayMenuItem[0] = new MenuItem(0, "Services", R.mipmap.ic_menu_title_service);
arrayMenuItem[1] = new MenuItem(1, getString(R.string.get_directions), R.mipmap.ic_directions);
arrayMenuItem[2] = new MenuItem(2, getString(R.string.amenities), R.mipmap.ic_amenities);
arrayMenuItem[3] = new MenuItem(3, "Others", R.mipmap.ic_menu_title_other);
arrayMenuItem[4] = new MenuItem(4, getString(R.string.about), R.mipmap.ic_about);
menuList.setAdapter(new MenuAdapter(getActivity(), arrayMenuItem));
return view;
}
onemap.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.onemap.widgets.MapView
xmlns:callout="http://schemas.android.com/apk/res/com.onemap.activities"
android:id="@id/mMapView"
calloutStyle="@xml/callout_style"
initExtent="29454.233386372267 39831.55546813806 30038.01821247406 40758.313879574656"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
callout:layout="@layout/callout" />
<ProgressBar
android:id="@id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
<com.onemap.widgets.SlidingMenu
xmlns:menu="http://schemas.android.com/apk/res/com.onemap.activities"
android:id="@id/mScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
menu:main_content="@id/mainContainer"
menu:menu_content="@id/menuContainer"
menu:menu_handle="@id/handle"
menu:menu_marginRight="@dimen/menu_margin_r">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<fragment
android:id="@id/menuContainer"
class="com.onemap.fragments.MainMenu"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:tag="MainMenu"
tools:layout="@layout/menu_main" />
<include
android:id="@id/mainContainer"
layout="@layout/widgets" />
</LinearLayout>
</com.onemap.widgets.SlidingMenu>
</RelativeLayout>
menu_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@id/btnSearch"
style="@android:style/TextAppearance.Widget.EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/menu_item_margin"
android:background="@drawable/selector_edittext_search"
android:clickable="true"
android:drawableLeft="@mipmap/ic_search"
android:drawablePadding="@dimen/menu_item_icon_padding"
android:gravity="center_vertical"
android:text="@string/search"
android:textColor="@color/selector_edittext_search_text" />
<LinearLayout
android:id="@id/listFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/menu_item_margin"
android:gravity="right">
<ImageView
android:id="@id/iv_arrow_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:paddingRight="@dimen/menu_item_icon_padding"
android:src="@mipmap/ic_arrow_up_disabled" />
<ImageView
android:id="@id/iv_arrow_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:paddingLeft="@dimen/menu_item_icon_padding"
android:paddingRight="@dimen/menu_item_icon_padding"
android:src="@mipmap/ic_arrow_down_enabled" />
</LinearLayout>
<ListView
android:id="@id/menu_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/listFooter"
android:layout_below="@id/btnSearch"
android:divider="@null"
android:dividerHeight="0.0dip"
android:fadingEdgeLength="0.0dip" />
</RelativeLayout>