android不会给我的片段充气

等等。

我有以下MainActivity.java

import java.util.Date;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.Toast;

import com.mydomain.myappname.CardoApplication;
import com.mydomain.myappname.R;
import com.mydomain.myappname.adapters.HomeTabsPagerAdapter;
import com.mydomain.myappname.extensions.SlidingTabLayout;

public class MainActivity extends AppCompatActivity {

    private ViewPager mViewPager;
    private HomeTabsPagerAdapter mPageAdapter;

    private Toolbar mToolbar;
    private SlidingTabLayout mTabs;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setViewsClassMembers();

        setSupportActionBar(mToolbar);
        mPageAdapter = new HomeTabsPagerAdapter(getSupportFragmentManager());

        mViewPager.setAdapter(mPageAdapter);
        // Assiging the Sliding Tab Layout View
        mTabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width

        // Setting Custom Color for the Scroll bar indicator of the Tab View
        mTabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
            @Override
            public int getIndicatorColor(int position) {
                return getResources().getColor(R.color.tabsScrollColor);
            }
        });

        // Setting the ViewPager For the SlidingTabsLayout
        mTabs.setViewPager(mViewPager);      
    }


    private void setViewsClassMembers() {
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mToolbar = (Toolbar) findViewById(R.id.tool_bar);
        mTabs = (SlidingTabLayout) findViewById(R.id.tabs);
    }


}

也有此ActiveFragment.java代码

package com.xplete.cardo.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.mydomain.myappname.R;

public class ActiveFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_active, container, false);
        return v;
    }
}

这是我的fragment_active.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_active"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="You Are In Tab active"
        android:id="@+id/textView"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

</fragment>

运行它时,出现以下错误消息:

10-25 13:49:09.014:E / AndroidRuntime(8699):android.view.InflateException:二进制XML文件第2行:夸大类片段的错误

我究竟做错了什么?

医学博士

您在XML布局中做错了。 <fragment>...</fragment>

更改为Layout喜欢<RelativeLayout> ...</RelativeLayout>

已更正:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_active"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="You Are In Tab active"
    android:id="@+id/textView"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

 </RelativeLayout>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

片段在充气1时给我一个错误

来自分类Dev

我的选择语句不会给我表格中的列

来自分类Dev

paho-mqtt不会给我排队的消息

来自分类Dev

安装nodejs模块不会给我命令

来自分类Dev

Android从Backstack还原给我空白片段

来自分类Dev

我该如何设置.htacess,这样才不会给我错误。(小白)

来自分类Dev

exit(1)不会给我1作为退出值吗?

来自分类Dev

如何只访问Object.Entries()中的值,以便React不会给我警告?

来自分类Dev

ls不会给我与cd + ls相同的文件夹

来自分类Dev

Alt gr +数字会更改语音类型,但不会给我按键

来自分类Dev

打印包含散列的变量不会给我任何输出

来自分类Dev

Android片段中的充气机

来自分类Dev

为什么这会给我InvalidArgumentError?

来自分类Dev

Git认为我是另一个用户,不会给我访问github存储库的权限

来自分类Dev

调用timer_tick函数不会给我'timer2_Tick'匹配委托'EventHandler'的重载

来自分类Dev

如果尝试在计算机上使用命令,但xrandr为什么会给我错误,但如果我在计算机中使用SSH命令却不会给我错误?

来自分类Dev

在Android Studio上运行我的第一次自动生成的代码会给我一个错误

来自分类Dev

为什么我的lisp函数会给我这个输出?

来自分类Dev

使用Linkedin代码登录会给我html验证错误

来自分类Dev

为什么每次都会给我String?

来自分类Dev

在APIGatewayProxyEvent中,哪个字段会给我URL?

来自分类Dev

加入工会会给我错误的结果

来自分类Dev

为什么setcookie()函数会给我警告。(包括代码)

来自分类Dev

为什么这会给我一个IndexError?

来自分类Dev

使用Get for ajax调用会给我500错误

来自分类Dev

为什么“ $ Namefile *”会给我这样的结果?

来自分类Dev

哪个桌面环境会给我这样的UI栏?

来自分类Dev

CMD:运行程序只会给我帮助页面

来自分类Dev

为什么这会给我带来细分错误?

Related 相关文章

  1. 1

    片段在充气1时给我一个错误

  2. 2

    我的选择语句不会给我表格中的列

  3. 3

    paho-mqtt不会给我排队的消息

  4. 4

    安装nodejs模块不会给我命令

  5. 5

    Android从Backstack还原给我空白片段

  6. 6

    我该如何设置.htacess,这样才不会给我错误。(小白)

  7. 7

    exit(1)不会给我1作为退出值吗?

  8. 8

    如何只访问Object.Entries()中的值,以便React不会给我警告?

  9. 9

    ls不会给我与cd + ls相同的文件夹

  10. 10

    Alt gr +数字会更改语音类型,但不会给我按键

  11. 11

    打印包含散列的变量不会给我任何输出

  12. 12

    Android片段中的充气机

  13. 13

    为什么这会给我InvalidArgumentError?

  14. 14

    Git认为我是另一个用户,不会给我访问github存储库的权限

  15. 15

    调用timer_tick函数不会给我'timer2_Tick'匹配委托'EventHandler'的重载

  16. 16

    如果尝试在计算机上使用命令,但xrandr为什么会给我错误,但如果我在计算机中使用SSH命令却不会给我错误?

  17. 17

    在Android Studio上运行我的第一次自动生成的代码会给我一个错误

  18. 18

    为什么我的lisp函数会给我这个输出?

  19. 19

    使用Linkedin代码登录会给我html验证错误

  20. 20

    为什么每次都会给我String?

  21. 21

    在APIGatewayProxyEvent中,哪个字段会给我URL?

  22. 22

    加入工会会给我错误的结果

  23. 23

    为什么setcookie()函数会给我警告。(包括代码)

  24. 24

    为什么这会给我一个IndexError?

  25. 25

    使用Get for ajax调用会给我500错误

  26. 26

    为什么“ $ Namefile *”会给我这样的结果?

  27. 27

    哪个桌面环境会给我这样的UI栏?

  28. 28

    CMD:运行程序只会给我帮助页面

  29. 29

    为什么这会给我带来细分错误?

热门标签

归档