---->> java.lang.RuntimeException:无法启动活动 ComponentInfo{sharedpreferenceex.app.htc.com.listview_lv/sharedpreferenceex.app.htc.com.listview_lv.MyGrid}:android.view.InflateException:二进制 XML 文件第 44 行:膨胀类 com.android.internal.widget.ActionBarContextView 时出错
---->>由以下原因引起:android.view.InflateException:二进制XML文件行#44:错误膨胀类com.android.internal.widget.ActionBarContextView
---->>由以下原因引起:java.lang.reflect.InitationTargetException
---->>由以下原因引起:java.lang.RuntimeException:无法解析索引 13 处的属性
我面临上述三个异常。我只是尝试运行一个应用程序以在活动中显示文本视图。这些异常到达活动本身的 onCreate 方法。
我还研究了所有的 stackoverflow 答案,但无法找出问题所在。
我的清单.xml
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyGrid"
android:label="@string/title_activity_my_grid" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
活动XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:textSize="25dp"
android:id="@+id/tv_example" />
活动代码
public class MyGrid extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_grid);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_my_grid, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}