gpt4 book ai didi

安卓 : Failed to resolve attribute at index 13

转载 作者:搜寻专家 更新时间:2023-11-01 07:50:21 26 4
gpt4 key购买 nike

---->> java.lang.RuntimeException: Unable to start activity ComponentInfo{sharedpreferenceex.app.htc.com.listview_lv/sharedpreferenceex.app.htc.com.listview_lv.MyGrid}: android.view.InflateException: Binary XML file line #44: Error inflating class com.android.internal.widget.ActionBarContextView

---->>Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class com.android.internal.widget.ActionBarContextView

---->>Caused by: java.lang.reflect.InvocationTargetException

---->>Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 13

我正面临上述三个异常。我只是想运行一个应用程序以在 Activity 中显示 TextView 。这些异常到达 Activity 本身的 onCreate 方法。

我也查看了所有 stackoverflow 的答案,但无法找出问题所在。

我的 list .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>

Activity 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" />

Activity 代码

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);
}

最佳答案

我想通了。我使用的移动设备不支持我在程序中使用的主题 (Styles.xml)。根据设备更改主题。在 styles.xml 中设置错误的主题是这些异常的原因。

关于安卓 : Failed to resolve attribute at index 13,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35594371/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com