小编use*_*234的帖子

Appcompat工具栏未显示导航抽屉

我试图在我的应用程序中配置以下内容:

  • 工具栏(Appcompat v7版)
  • 导航抽屉
  • Pre- Lollipop Appcompat v7材料主题

我按照这里的说明操作:http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html

但是,在主题中声明.NoActionBar之后,以及将工具栏放在布局中,我的工具栏不会显示.我最终得到的正是你在宣布没有动作栏时所期望的 - 没有动作栏.这是布局:

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

<!-- Toolbar -->
<include layout="@layout/toolbar"/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layout_main"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <Spinner
        android:id="@+id/spinner_main"
        android:visibility="gone"
        android:textAlignment="center"
        android:gravity="center"
        android:layout_gravity="center_horizontal"
        android:entries="@array/error_loading_content_array"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

    <FrameLayout
        android:id="@+id/container"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0px"></FrameLayout>

</LinearLayout>

<fragment
    android:id="@+id/navigation_drawer"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:name=".NavigationDrawerFragment"
    tools:layout="@layout/fragment_navigation_drawer"/>
Run Code Online (Sandbox Code Playgroud)

Toolbar.xml:

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)

在MainActivity.java中:

// Load view/layout
setContentView(R.layout.guidelib_activity_main);

// TODO: Toolbar not showing
mToolbar …
Run Code Online (Sandbox Code Playgroud)

android android-appcompat navigation-drawer android-5.0-lollipop android-toolbar

22
推荐指数
1
解决办法
2万
查看次数

AdMob:AdMob广告单元ID疑难解答的升级版

我最近刚升级到新版AdMob(之前的版本称为Legacy AdMob).

我将我的信息从旧版AdMob导入升级版本.我现在不确定如何添加新的广告单元.

我有两(2)个广告.一个是主屏幕广告(广告1),另一个是在不同的屏幕上(广告2).广告1是在旧版AdMob下创建的.它下面有一个旧版发布者ID和一个旧版中介ID.我最近创建了广告2.它指定"广告单元ID".

当然,Google的开发人员资源尚未更新(https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=en_US#xml).

我的问题是:1.我是否继续使用传统 AdMob PUBLISHER ID作为广告1?2.对于Ad 2,我是否使用我的新发布商ID(我注意到AdMob在从Legacy切换时给了我一个新的发布商ID)?

基本上,现在我正在使用AdMob的升级版本(从旧版AdMob转换;旧AdMob),我使用哪个ID*来确保收到我的收入?

*新/升级后的AdMob下的新ID也会更长,并从以下内容开始:

CA-APP-pub- [AD_UNIT_ID_NUMBER_HERE]

pub- [PUBLISHER_ID_HERE]

我是否包含上面提到的前缀?

android ads admob

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

Android:重写方法时出错

我正在关注官方Android文档中的页面翻转教程:http: //developer.android.com/training/animation/screen-slide.html

覆盖getItem(int)方法时,我收到此错误:

'ScreenSlidePagerAdapter类'中的getItem(int)与'android.support.v4.app.FragmentStatePagerAdapter'中的getItem(int)冲突; 尝试使用不兼容的返回类型.

我的自定义片段类扩展了Fragment,就像在教程中一样.

为了确保我没有做错,我复制并粘贴了示例代码以测试它(更改所需的名称).

我究竟做错了什么?

android fragment android-viewpager

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

无法使RecyclerView.Adapter正确显示

我在这里遵循了这个例子:https://developer.android.com/training/material/lists-cards.html

发生了什么:

列表(RecyclerView)在滚动时混合数据.即,当我向下滚动后向上滚动时,会重复一些列表项,而不会显示正确的内容.

这是我的onBindViewHolder方法:

// cardsData is a List of MyCardItem (MyCardItem is just a holder of information,
// such as an id, String title, String summary, and other info to display on a card
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position)
{
    // Update view here
    if (!cardsData.isEmpty())
    {
        viewHolder.updateDisplay(cardsData.get(position), activity, position);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我updateDisplay在ViewHolder类中找到的方法:

// Set ID
if (item.getID() != null)
{
    mIDView.setText(item.getID());
}

// Set Title
if (item.getTitle() != …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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