昨天(17-10-2014)我已经更新了Android SDK和support-library-v4.jar我的应用程序,现在我得到了相关的弃用警告ActionBarDrawerToggle,阅读文档似乎我必须使用ActionBarDrawerTogglein support-library-v7.appcompact.jar.
这里我的活动的一些部分可能是相关的:
import android.app.ActionBar;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class MyActivity extends FragmentActivity {
private ActionBar bar;
private CustomActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawer;
private ListView mDrawerList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infoviewer);
bar = this.getActionBar();
bar.setDisplayHomeAsUpEnabled(true);
bar.setHomeButtonEnabled(true);
bar.setDisplayShowTitleEnabled(false);
mDrawer = …Run Code Online (Sandbox Code Playgroud) 最近,我读了这些帖子:
但是,他们都没有给我一个关于创建新的详细示例FloatingActionButton.很难理解,我问这个问题.
谁能给我一个关于它的例子?
任何帮助都很值得赞赏.提前致谢.
编辑
我刚刚在FloatingActionButton(FAB)上发现了一些问题,我想改进另一个答案.请参阅下面的答案.
android android-support-library floating-action-button android-design-library
我正在开发一个支持Android> = 4.0的应用程序.它使用android.app包中的碎片.由于我遇到了4.0中较旧的片段实现的问题,就像这个,已经在支持库中修复了,我正在考虑从支持库切换回片段实现,以获得更可靠和一致的实现.
你对这个有什么看法?在为Android 4开发时,您是否正在使用支持库中的片段,即使它们已经可用?
我不确定这个错误意味着什么.
Execution failed for task ':excelSior:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/util/TimeUtils.class
Run Code Online (Sandbox Code Playgroud)
我目前正在使用android-support-v4.jar我的库
dependencies {
compile project(':addThisSDK')
compile project(':centeredContentButton')
compile project(':googleplayservices_lib')
compile files('libs/adxtag2.4.6.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/crittercism_v4_4_0_sdkonly.jar')
compile files('libs/dd-plist.jar')
compile files('libs/FiksuAndroidSDK_4.1.1.jar')
compile files('libs/iqengines-sdk-barcode.jar')
compile files('libs/irEventTracker-1.2.jar')
compile files('libs/jolt-core-0.0.7.jar')
compile files('libs/json-utils-0.0.7.jar')
compile files('libs/jsoup-1.7.2.jar')
compile files('libs/kooaba-api-v4-java.jar')
compile 'com.android.support:multidex:1.0.0'
}
Run Code Online (Sandbox Code Playgroud)
在gradle sync期间,错误不会显示.就在我尝试运行应用程序时
可能是什么问题呢?
android android-support-library android-gradle-plugin android-multidex
我正在为4.0和4.1平板电脑编写一个应用程序,我不想使用支持库(如果不需要),而只使用4.x api.
所以我的目标平台定义为:> = 4.0且<= 4.1
该应用程序具有多窗格布局(两个片段,左侧一个小片段,右侧一个内容片段)和一个带标签的操作栏.
与此类似:

单击操作栏上的选项卡可更改"外部"片段,然后内部片段是具有两个嵌套片段的片段(1.左侧小片段,2.宽内容片段).
我现在想知道替换片段,特别是嵌套片段的最佳做法是什么.ViewPager是支持库的一部分,此类没有本机4.x替代方案.在我看来似乎是"弃用".- http://developer.android.com/reference/android/support/v4/view/ViewPager.html
然后我阅读了Android 4.2的发行说明ChildFragmentManager,这是一个不错的选择,但我的目标是4.0和4.1,所以这也不能使用.
ChildFragmentManager 仅适用于4.2
遗憾的是,即使在整个Android开发人员指南中,也没有任何好的示例显示没有支持库的片段使用的最佳实践; 尤其是关于嵌套片段的一切.
所以我想知道:如果不使用支持库及其附带的所有内容,是否根本不可能使用嵌套片段编写4.1应用程序?(需要使用FragmentActivity而不是Fragment等?) 或者什么是最佳实践?
我目前在开发中遇到的问题正是这个陈述:
Android支持库现在还支持嵌套片段,因此您可以在Android 1.6及更高版本上实现嵌套片段设计.
注意:当布局包含a时,您无法将布局扩展为片段
<fragment>.仅在动态添加到片段时才支持嵌套片段.
因为我在XML中定义了嵌套片段,这显然会导致如下错误:
Caused by: java.lang.IllegalArgumentException: Binary XML file line #15: Duplicate id 0x7f090009, tag frgCustomerList, or parent id 0x7f090008 with another fragment for de.xyz.is.android.fragment.CustomerListFragment_
Run Code Online (Sandbox Code Playgroud)
目前,我为自己总结一下:即使在4.1上,当我甚至不想以2.x平台为目标时,如果没有支持库,则无法在屏幕截图中显示嵌套片段.
(这实际上可能更像是一个wiki条目而不是一个问题,但也许其他人之前已经管理过它).
更新:
一个有用的答案是:Fragment Inside Fragment
android android-fragments android-support-library android-nested-fragment
使用v7首选项支持库中的新PreferenceFragmentCompat:http://developer.android.com/tools/support-library/features.html#v7-preference,我收到此错误
E java.lang.IllegalStateException: Must specify preferenceTheme in theme
E at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:202)
Run Code Online (Sandbox Code Playgroud)
应该设置什么主题?
更新:我尝试过使用
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
正如@Bogato所建议的那样,它看起来并不正确,即使在Lollipop上也看起来非常Holo.
支持库:
原生偏好:
android android-fragments android-support-library preferencefragment preference-v7
我正在使用从Android 4.3(API级别18)开始提供的新v7 appcompat库.
无论showAsAction中为菜单项指定了什么,它都没有显示 - 它总是创建溢出菜单图标,甚至在菜单下放置一个菜单项.
试图将菜单添加到这样的活动:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_sizes, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud)
这是我的菜单xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_add_size"
android:title="@string/menu_add_item"
android:orderInCategory="10"
android:showAsAction="always"
android:icon="@android:drawable/ic_menu_add" />
</menu>
Run Code Online (Sandbox Code Playgroud)
它是新支持库v7的错误,还是代码有问题?我以前多次使用与ActionBarSherlock类似的代码.
android menuitem android-support-library android-actionbar-compat
当我在NestedScrollView中添加RecyclerView时,我得到一个奇怪的滚动行为.
发生的事情是,只要滚动视图的行数多于屏幕中显示的行数,一旦启动活动,NestedScrollView就会从顶部开始偏移(图像1).如果滚动视图中的项目很少,以便可以一次显示它们,则不会发生这种情况(图2).
我使用的是支持库的23.2.0版.
图1:错误 - 从顶部偏移开始
图2:正确 - 回收者视图中的几个项目
我粘贴在我的布局代码下面:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title:"
style="@style/TextAppearance.AppCompat.Caption"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/bodyPadding"
style="@style/TextAppearance.AppCompat.Body1"
android:text="Neque porro quisquam est qui dolorem ipsum"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Subtitle:"
style="@style/TextAppearance.AppCompat.Caption"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Body1"
android:padding="@dimen/bodyPadding"
android:text="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv"
android:focusable="false" …Run Code Online (Sandbox Code Playgroud) android android-support-library android-recyclerview android-nestedscrollview
我刚刚安装了新的Android Studio,我正在寻找一种方法来导入Android的支持库.
那个选项在哪里?在Eclipse中只需两次点击.我用谷歌搜索但没有发现任何东西.当然它太新了.
如何设置页脚设置和配置文件项NavitationView?通过电子邮件导航抽屉看起来像收件箱.该NavitationView项目是由菜单资源膨胀,但我不知道如何底部的项目设置菜单资源,或者我怎么可以设置自定义视图NavigationView或底部偏移?我试过把它<LinearLayout...>作为页脚视图,但在小屏幕上,页脚放置项目,我无法滚动菜单,我试图设置页脚填充NavigationView,但页脚也采取填充.
这不是在小屏幕上滚动:
<android.support.design.widget.NavigationView
android:id="@+id/drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/kuona_drawer_header"
app:menu="@menu/drawer">
<LinearLayout...>
</android.support.design.widget.NavigationView>
Run Code Online (Sandbox Code Playgroud)

滚动,但页脚在菜单项上:
<android.support.design.widget.NavigationView
android:id="@+id/drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:paddingBottom="96dp"
app:headerLayout="@layout/kuona_drawer_header"
app:menu="@menu/drawer">
<LinearLayout...>
</android.support.design.widget.NavigationView>
Run Code Online (Sandbox Code Playgroud)

抽屉菜单res/menu/drawer.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/action_current_list"
android:checked="true"
android:icon="@drawable/ic_current_list"
android:title="@string/current_list" />
<item
android:id="@+id/action_manage_lists"
android:icon="@drawable/ic_my_lists"
android:title="@string/my_lists" />
<item
android:id="@+id/action_search_products"
android:icon="@drawable/ic_search_black_24dp"
android:title="@string/search_products" />
<item
android:id="@+id/action_deals"
android:icon="@drawable/ic_product_promo"
android:title="@string/deals" />
</group>
</menu>
Run Code Online (Sandbox Code Playgroud)