`无法加入并且它给我这个logcat错误
AGPBI: {"kind":"error","text":"Tag \u003cItem\u003e can not appear inside \u003cstring-array\u003e, only \u003citem\u003e","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\src\\main\\res\\values\\strings.xml","position":{"startLine":6,"startColumn":4,"startOffset":298,"endLine":10,"endColumn":19,"endOffset":429}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.Widget.AppCompat.DrawerArrowToggle.Common\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-hdpi-v4\\values-hdpi-v4.xml","position":{"startLine":2}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027barLength\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\appcompat-v7\\23.4.0\\res\\values-hdpi-v4\\values-hdpi-v4.xml","position":{"startLine":2,"startColumn":4,"startOffset":55,"endLine":6,"endColumn":13,"endOffset":327}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027drawableSize\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\appcompat-v7\\23.4.0\\res\\values-hdpi-v4\\values-hdpi-v4.xml","position":{"startLine":2,"startColumn":4,"startOffset":55,"endLine":6,"endColumn":13,"endOffset":327}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027gapBetweenBars\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\appcompat-v7\\23.4.0\\res\\values-hdpi-v4\\values-hdpi-v4.xml","position":{"startLine":2,"startColumn":4,"startOffset":55,"endLine":6,"endColumn":13,"endOffset":327}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.Widget.Design.TabLayout\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-sw600dp-v13\\values-sw600dp-v13.xml","position":{"startLine":22}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027tabGravity\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\design\\23.4.0\\res\\values-sw600dp-v13\\values-sw600dp-v13.xml","position":{"startLine":11,"startColumn":4,"startOffset":677,"endLine":14,"endColumn":12,"endOffset":854}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027tabMode\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\design\\23.4.0\\res\\values-sw600dp-v13\\values-sw600dp-v13.xml","position":{"startLine":11,"startColumn":4,"startOffset":677,"endLine":14,"endColumn":12,"endOffset":854}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.Widget.Design.TabLayout\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-land\\values-land.xml","position":{"startLine":8}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027tabGravity\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\design\\23.4.0\\res\\values-land\\values-land.xml","position":{"startLine":2,"startColumn":4,"startOffset":55,"endLine":5,"endColumn":12,"endOffset":232}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027tabMode\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\exploded-aar\\com.android.support\\design\\23.4.0\\res\\values-land\\values-land.xml","position":{"startLine":2,"startColumn":4,"startOffset":55,"endLine":5,"endColumn":12,"endOffset":232}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.Theme.AppCompat.Dialog.FixedSize\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-large-v4\\values-large-v4.xml","position":{"startLine":13}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.Theme.AppCompat.Light.Dialog.FixedSize\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-large-v4\\values-large-v4.xml","position":{"startLine":14}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":2}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":3}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat.Dialog\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":4}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat.Dialog.Alert\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":5}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat.Dialog.MinWidth\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":6}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat.DialogWhenLarge\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":7}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Theme.AppCompat.NoActionBar\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-night-v8\\values-night-v8.xml","position":{"startLine":8}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.V7.Theme.AppCompat.Dialog\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-v11\\values-v11.xml","position":{"startLine":40}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027Base.V7.Theme.AppCompat.Light.Dialog\u0027.","sources":[{"file":"C:\\Users\\Squirrel\\Documents\\MyCodes\\ClickAwayTechnologies\\app\\build\\intermediates\\res\\merged\\debug\\values-v11\\values-v11.xml","position":{"startLine":45}}],"original":"","tool":"AAPT"}
经过简短的研究后,我了解到我的错误原因是
<string-array name="tabs">
<Item>Tab 1</Item>
<Item>Tab 2</Item>
<Item>Tab 3</Item>
</string-array>
我正在尝试解决它,但我无法找到解决问题的最佳方法,可以帮助他们。
我的代码的这一部分
pager.setAdapter(new viewPagerAdapter(getSupportFragmentManager()));
pager.setOnPageChangeListener(new pager.SimpleOnPageChangeListener() {
public void onPageSelected(int position) {
tabHost.setSelectedNavigationItem(position);
}
});
通过不识别功能
显示错误SimpleOnPageChangeListener()
我也很感激,如果我能解决这个问题
答案 0 :(得分:1)
就我而言,我必须更改compileSDKVersion
以与支持库版本匹配以消除此错误。
我的支持库版本为27.1.1
,而compileSDKVersion
为23
。将compileSDKVersion
更改为27
,从而更正了错误。
答案 1 :(得分:0)
我能够修复上述所有错误。
AGPBI的原因是因为我使用了标签<Item>
所以我把它换成了
<string-array name="tabs">
<item>Tab 1</item>
<item>Tab 2</item>
<item>Tab 3</item>
</string-array>
对于下一个问题,我必须更新一个新类ViewPager
而不是之前初始化的类分页器,所以现在我的代码看起来像。
pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
@Override
public void onPageSelected(int position) {
tabHost.setSelectedNavigationItem(position);
}
});
现在它完美无缺。