小编Pan*_*kaj的帖子

android.support.design.widget.TabLayout以编程方式选择Tab

我使用的是android.support.design.widget.TabLayout.它有两个选项卡,如果用户选择第二个选项卡在特定条件下,我希望用户重定向到第一个选项卡,并禁止他转到sencond选项卡,直到条件匹配.为了实现这一点,我试过,

tabLayout.getTabAt(0).select(); 
Run Code Online (Sandbox Code Playgroud)

但它没有重新选择第一个标签

android android-tablayout

23
推荐指数
1
解决办法
3万
查看次数

选中时,在TabLayout中的Tab上更改图像

我正在使用Design TabLayout,

<android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabBackground="@color/ColorPrimary"
            app:tabIndicatorColor="@color/orange"
            app:tabIndicatorHeight="3dp"
            />
Run Code Online (Sandbox Code Playgroud)

我已经在Tabs中添加了customview

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

    <ImageView
        android:id="@+id/imgTab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/tab_image"
        android:layout_centerHorizontal="true"
        android:focusable="true"
        android:focusableInTouchMode="true"/>

    <TextView
        android:id="@+id/tabTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/imgTab"
        android:text="Home"
        android:background="@null"
        android:layout_centerHorizontal="true"
        android:textColor="@color/selector_tab_text"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

tab.setCustomView(视图);

我想在选择Tab时在自定义视图中更改图像.在imageview上使用Selector尝试它不起作用.我无法在运行时将视图分配给Tab,它只包含setCustomView方法.怎么实现呢?

android android-tablelayout android-tabs

5
推荐指数
1
解决办法
3830
查看次数

Android Google跟踪代码管理器

我正在按照我的营销团队的要求为Android应用程序V4实施Google跟踪代码管理器以供将来使用,我从未在网站上使用GTM,所以我在这方面很天真.

我根据官方网站上的说明创建了帐户,容器和标签.我已将标记管理器与Google Analytics跟踪ID相关联.我已根据网站上的说明在我的应用程序中编写代码并将容器下载到原始文件夹.

当我运行我的应用程序时,它会在logcat中给出警告和详细信息

W/GoogleTagManager:Resource是UTF-8编码的字符串,但不包含JSON容器

D/GoogleTagManager:资源不在磁盘上

现在我不确定这里的问题是什么,数据也没有反映在分析中.

android google-analytics google-tag-manager

1
推荐指数
1
解决办法
3144
查看次数