使用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代码找到方法.有办法吗?
我想实现自定义ActionBar
,必须如下所示:
所以问题:
ActionBar
?ActionBar
或什么?我的应用程序经常会崩溃,我的日志会显示为:
@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree
Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
Run Code Online (Sandbox Code Playgroud)
有时code=2
,但总是Fatal signal 11
和invalid 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) 我怎么能让一个操作栏在中心有徽标,两边有两个动作项?
我将使用ActionBar Sherlock.
我有一个ListView
与fastScrollAlwaysVisible
和fastScrollEnabled
均设置为true
.实现SectionIndexer
到我Adapter
和AlphabetIndexer
我之后,fast scroll thumb
当我滚动时,我的意志消失,然后在我到达列表的顶部或底部时重新出现.对于为什么会这样,我很无能为力.我之前没有经历过.
以下所有内容都有效AlphabetIndexer
.我的问题是为什么我的快速滚动拇指在我滚动时消失了,我怎么能阻止它消失?
无论是否fast scroll
是始终可见无所谓.每当fast scroll
可见时,fast scroll thumb
它就不存在,它就会消失,这就是我的问题.此外,当我删除像我打算AlphabetIndexer
的fast scroll thumb
作品.一切都成功地运作Activity
,但当我加载我ListView
的Fragment
东西最终像我解释.
这是我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) 我在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
我在我的应用程序中实现了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) 我得到了导航抽屉的列表视图,如何在列表视图的底部放置"添加好友"列表项,"设置"对齐.
更新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)
设置项成功显示在列表视图中的最后一个项目上.但是我怎样才能让它在底部粘住并对齐?谢谢.
我下载了最新的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) 我有一个RecyclerView
带滚动条的不同高度的项目.由于项目的高度不同,滚动条会更改其垂直大小,具体取决于当前显示的项目(请参见屏幕截图).我创建了一个示例项目,在这里显示问题.
编辑:滚动条的位置和高度可以通过覆盖进行控制RecyclerViews
computeVerticalScrollOffset
,computeVerticalScrollRange
并computeVerticalScrollExtent
.我不知道如何实现这些以使滚动条与动态项目高度正常工作.
我想,问题是RecyclerView
根据当前可见的项目估算所有项目的总高度,并相应地设置滚动条的位置和高度.解决这个问题的一种方法可能是更好地估计所有物品的总高度.