小编adn*_*eal的帖子

如何在NavigationView中为项目设置自定义字体?

使用new NavigationView,我们可以通过XML菜单资源设置抽屉的项目.

有了它,我们可以设置每个项目

<item
  android:id="@+id/drawer_my_account"
  android:icon="@drawable/ic_my_account"
  android:title="@string/drawer_my_account" />
Run Code Online (Sandbox Code Playgroud)

但现在,我想为抽屉中的每个项目设置一个自定义字体,我无法通过XML或Java代码找到方法.有办法吗?

android android-design-library navigationview

64
推荐指数
6
解决办法
6万
查看次数

如何在Android中使用自定义按钮实现自定义操作栏?

我想实现自定义ActionBar,必须如下所示:

在此输入图像描述

所以问题:

  1. 如何实现自定义视图之类的按钮:只是一些图像?
  2. 我怎样才能画出一条线ActionBar
  3. 如何在没有分隔线的情况下实现按钮:添加标签ActionBar或什么?

java android android-actionbar

60
推荐指数
1
解决办法
12万
查看次数

无效的堆地址和致命信号11

我的应用程序经常会崩溃,我的日志会显示为:

@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
Run Code Online (Sandbox Code Playgroud)

有时code=2,但总是Fatal signal 11invalid heap address.

我已经尝试过研究这意味着什么,以及如何解决它.这个帖子最有帮助 ; 但是,我仍然没有解决方案.

当我运行几个AsyncTasks下载多个图像时,会发生错误.

这是我的主要 AsyncTask

public class FetchArtistImages extends AsyncTask<Void, Integer, String[]> implements Constants {

private final WeakReference<Context> contextReference;

public FetchArtistImages(Context context) {
    contextReference = new WeakReference<Context>(context);
}

@Override
protected String[] doInBackground(Void... params) {
    String[] projection = new String[] {
            Audio.Artists._ID, Audio.Artists.ARTIST
    };
    String sortOrder = Audio.Artists.DEFAULT_SORT_ORDER;
    Uri uri = …
Run Code Online (Sandbox Code Playgroud)

heap android android-asynctask

42
推荐指数
2
解决办法
4万
查看次数

ActionBar徽标居中,两侧是Action项目

我怎么能让一个操作栏在中心有徽标,两边有两个动作项?

在此输入图像描述

我将使用ActionBar Sherlock.

android center graphical-logo android-actionbar

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

滚动AlphabetIndexer时,快速滚动缩略图消失

我有一个ListViewfastScrollAlwaysVisiblefastScrollEnabled均设置为true.实现SectionIndexer到我AdapterAlphabetIndexer我之后,fast scroll thumb当我滚动时,我的意志消失,然后在我到达列表的顶部或底部时重新出现.对于为什么会这样,我很无能为力.我之前没有经历过.

以下所有内容都有效AlphabetIndexer.我的问题是为什么我的快速滚动拇指在我滚动时消失了,我怎么能阻止它消失?

无论是否fast scroll始终可见无所谓.每当fast scroll可见时,fast scroll thumb它就不存在,它就会消失,这就是我的问题.此外,当我删除像我打算AlphabetIndexerfast scroll thumb作品.一切都成功地运作Activity,但当我加载我ListViewFragment东西最终像我解释.

这是我Adapter的意思ListView:

private class AlbumsAdapter extends SimpleCursorAdapter implements
        SectionIndexer {

private AlphabetIndexer mIndexer;

// I have to override this because I'm using a `LoaderManager`
@Override
    public Cursor swapCursor(Cursor cursor) { …
Run Code Online (Sandbox Code Playgroud)

java android android-listview

32
推荐指数
2
解决办法
4103
查看次数

AppBarLayout和Toolbar的新Android设计库错误

我在github和这里使用基于这个例子的新的Android设计库chrisbanes/cheesesquare

我运行了这个例子,我遇到了CheeseDetailActivity里面的工具栏问题.工具栏未按预期显示.看看下面的图片:

在第一张图像中,您可以看到工具栏未正确显示.

在此输入图像描述

在第二个图像中,您可以看到工具栏显示正确但通知栏为白色.发生这种情况是因为我从actiivty_detail.xml中删除android:fitsSystemWindows="true"android.support.design.widget.CoordinatorLayout

在此输入图像描述

我认为这fitsSystemWindows应该是真的,问题与此有关,android.support.design.widget.AppBarLayout但我不知道如何解决这个问题.我尝试marginTop了相同的高度,notificationBar但它没有工作.

任何建议表示赞赏:)

这是以下内容的一部分activity_detail.xml:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/detail_backdrop_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">

        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin" />

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-toolbar android-design-library

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

如何在SwipeRefreshLayout中调整向下滑动距离?

我在我的应用程序中实现了SwipeRefreshLayout.我需要更改必须向下滚动的高度来调用onRefresh()方法.我应该使用哪种方法来添加自定义高度?

SwipeRefreshLayout的实现

private SwipeRefreshLayout swipeLayout;
Run Code Online (Sandbox Code Playgroud)

在oncreate

swipeLayout   = (SwipeRefreshLayout)view.findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
        swipeLayout.setColorScheme(android.R.color.holo_blue_dark, 
                android.R.color.holo_green_dark, 
                android.R.color.holo_purple, 
                android.R.color.holo_orange_dark);   
        swipeLayout.setSoundEffectsEnabled(true);
Run Code Online (Sandbox Code Playgroud)

在onrefresh方法中实现AsyncTask

   @Override
public void onRefresh() 
{
    // Asynctask to perform some task  

}
Run Code Online (Sandbox Code Playgroud)

android android-support-library swiperefreshlayout

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

如何将列表项放在导航抽屉列表视图的底部,如Foursquare

我得到了导航抽屉的列表视图,如何在列表视图的底部放置"添加好友"列表项,"设置"对齐.

在此输入图像描述

更新1
我在页脚视图中添加了设置视图.

View settingView = getLayoutInflater().inflate(R.layout.drawer_list_item, null);
TextView textView = (TextView)settingView.findViewById(R.id.drawer_list_item_text_view);
textView.setText("Settings");
drawerListView.addFooterView(settingView); 
Run Code Online (Sandbox Code Playgroud)

设置项成功显示在列表视图中的最后一个项目上.但是我怎样才能让它在底部粘住并对齐?谢谢.

android android-listview navigation-drawer

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

为什么我的Activity扩展了ActionBarActivity?

我下载了最新的SDK版本,当我创建一个新的Android项目时MainActivity,自动生成的扩展ActionBarActivity,但我想扩展Activity.

public class MainActivity extends ActionBarActivity {

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

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on …
Run Code Online (Sandbox Code Playgroud)

android android-activity android-actionbar

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

RecyclerView与不同高度的项目:滚动条

我有一个RecyclerView带滚动条的不同高度的项目.由于项目的高度不同,滚动条会更改其垂直大小,具体取决于当前显示的项目(请参见屏幕截图).我创建了一个示例项目,在这里显示问题.

  1. 有没有人有同样的问题并修复它?
  2. 如何覆盖滚动条高度和位置的计算以得出自己的实现?

编辑:滚动条的位置和高度可以通过覆盖进行控制RecyclerViews computeVerticalScrollOffset,computeVerticalScrollRangecomputeVerticalScrollExtent.我不知道如何实现这些以使滚动条与动态项目高度正常工作.

我想,问题是RecyclerView根据当前可见的项目估算所有项目的总高度,并相应地设置滚动条的位置和高度.解决这个问题的一种方法可能是更好地估计所有物品的总高度.

大滚动条 小滚动条

android scrollbar android-recyclerview

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