Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Studio选项卡和ViewPager渲染_Android_Xml_Android Layout_Android Studio_Android Support Library - Fatal编程技术网

Android Studio选项卡和ViewPager渲染

Android Studio选项卡和ViewPager渲染,android,xml,android-layout,android-studio,android-support-library,Android,Xml,Android Layout,Android Studio,Android Support Library,我一直在开发一个简单的应用程序,其中涉及片段。我在XML文件中使用了viewpager和TableLayout。显示一个错误:呈现问题和2个警告:i)缺少样式ii)未能实例化一个或多个类。 在“渲染问题”中,显示以下错误: “在当前主题中找不到样式“tabStyle” 缺少样式: 缺少样式。是否为此版面选择了正确的主题?请使用版面上方的“主题”组合框选择其他版面,或修复主题样式引用 中未能实例化一个或多个类: “无法实例化以下类: -android.support.design.widget.T

我一直在开发一个简单的应用程序,其中涉及片段。我在XML文件中使用了viewpager和TableLayout。显示一个错误:呈现问题和2个警告:i)缺少样式ii)未能实例化一个或多个类。 在“渲染问题”中,显示以下错误: “在当前主题中找不到样式“tabStyle”

缺少样式: 缺少样式。是否为此版面选择了正确的主题?请使用版面上方的“主题”组合框选择其他版面,或修复主题样式引用

中未能实例化一个或多个类: “无法实例化以下类: -android.support.design.widget.TabLayout(打开类,显示异常,清除缓存) -android.support.v4.view.ViewPager(打开类,显示异常,清除缓存) 提示:在自定义视图中使用View.isInEditMode()可以跳过代码或在IDE中显示示例数据。如果这是意外错误,您也可以尝试构建项目,然后手动刷新布局。异常详细信息java.lang.ClassNotFoundException:android.View.View$OnUnandledKeyEventListener“

Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.utkarsh.kannadaseekhae">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" 
 />
        </intent-filter>
    </activity>

</application>
安卓{ 编译DK28版 默认配置{ applicationId“com.example.utkarsh.kannadasekhae” 第15版 targetSdkVersion 28 版本代码1 版本名称“1.0” 测试仪器运行器 “android.support.test.runner.AndroidJUnitRunner” } 建筑类型{ 释放{ minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), “proguard规则。专业版” } } }

MainActivity.java:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set the content of the activity to use the activity_main.xml 
 layout file
    setContentView(R.layout.activity_main);

    // Find the view pager that will allow the user to swipe between 
fragments
    ViewPager viewPager = findViewById(R.id.viewpager);

    // Create an adapter that knows which fragment should be shown on 
each page
    CategoryAdapter adapter = new CategoryAdapter(this, 
getSupportFragmentManager());

    // Set the adapter onto the view pager
    viewPager.setAdapter(adapter);

    // Find the tab layout that shows the tabs
    TabLayout tabLayout = findViewById(R.id.tabs);

    // Connect the tab layout with the view pager. This will
    //   1. Update the tab layout when the view pager is swiped
    //   2. Update the view pager when a tab is selected
    //   3. Set the tab layout's tab names with the view pager's 
adapter's titles
    //      by calling onPageTitle()
    tabLayout.setupWithViewPager(viewPager);
    }
}

只需将支持库版本更改为
alpha1

它应该看起来

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
apply plugin: 'com.android.application'
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint- 
layout:1.1.2'
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.android.support:design:28.0.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.2'
}
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set the content of the activity to use the activity_main.xml 
 layout file
    setContentView(R.layout.activity_main);

    // Find the view pager that will allow the user to swipe between 
fragments
    ViewPager viewPager = findViewById(R.id.viewpager);

    // Create an adapter that knows which fragment should be shown on 
each page
    CategoryAdapter adapter = new CategoryAdapter(this, 
getSupportFragmentManager());

    // Set the adapter onto the view pager
    viewPager.setAdapter(adapter);

    // Find the tab layout that shows the tabs
    TabLayout tabLayout = findViewById(R.id.tabs);

    // Connect the tab layout with the view pager. This will
    //   1. Update the tab layout when the view pager is swiped
    //   2. Update the view pager when a tab is selected
    //   3. Set the tab layout's tab names with the view pager's 
adapter's titles
    //      by calling onPageTitle()
    tabLayout.setupWithViewPager(viewPager);
    }
}
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'