
目前的FAB
我想知道如何将'com.android.support:design:22.2.0'库提供的FAB(浮动操作按钮)小部件的图标颜色从绿色更改为白色.
style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
<color name="color_primary">#00B33C</color>
<color name="color_primary_dark">#006622</color>
<color name="accent">#FFB366</color>
Run Code Online (Sandbox Code Playgroud)
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include android:id="@+id/toolbar" layout="@layout/toolbar" />
<TextView android:id="@+id/text"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:paddingTop="16dp"
android:textSize="20sp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:paddingBottom="16dp" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="@android:drawable/ic_input_add"
android:layout_margin="24dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:borderWidth="0dp" />
Run Code Online (Sandbox Code Playgroud)
如何使用提供Cat的组件创建Dog实例.
public final class Dog {
private final Cat mCat;
public final static String TAG = "Dog";
@Inject public Dog(Cat cat) {
mCat = cat;
Log.e(TAG, "Dog class created");
}
}
Run Code Online (Sandbox Code Playgroud)
在尝试使用Dagger 2一段时间后,我不知道如何使用构造函数注入 - 一个提示会很好,谢谢.
编辑:
这个问题怎么了?在使用Dagger 2之后,按照几个教程并阅读官方文档,我不知道如何使用构造函数注入功能,这就是我在这里问的原因.而不是使用@Inject将Cat依赖项注入Dog中,我可以编写一个提供Dog对象的DogModule,但是Dog将只是一个普通的Java类.现场注入效果很好(有很多示例显示如何使用它)但是我需要做什么才能使用构造函数注入?
我想将GestureDetector添加到活动的所有视图(视图组),而不是手动将其分配给每个视图.现在onFling()仅在向后滑动时激活,但在滑动例如button1时不激活.
package com.app.example;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class ExampleActivity extends Activity {
Context mContext = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
LinearLayout parent = new LinearLayout(mContext);
parent.setOrientation(LinearLayout.VERTICAL);
parent.setBackgroundColor(Color.RED);
Button button1 = new Button(mContext);
button1.setText("Button 1");
Button button2 = new Button(mContext);
button2.setText("Button 2");
parent.addView(button1);
parent.addView(button2);
final GestureDetector gestureDetector = new GestureDetector(
new MyGestureDetector());
parent.setOnTouchListener(new OnTouchListener() …Run Code Online (Sandbox Code Playgroud) 如何过滤IO [Maybe String]以仅保留Just列表的值>>=并保留IO上下文.
-- returns Just, if the passed binary-name is not present on the system
binDoesntExist :: String -> IO (Maybe String)
binDoesntExist ...
Run Code Online (Sandbox Code Playgroud)
我没有bind-operator的当前解决方案:
missingBin :: [String] -> IO [String]
missingBin xs = do
ys <- mapM (\x -> binDoesntExist x) xs
return $ catMaybes ys
Run Code Online (Sandbox Code Playgroud)
我目前正在学习Haskell并尝试了解如何使用标准库的不同功能.我的解决方案有效,但我想有更简洁的方法.
如何显示使用整个屏幕宽度的SearchView 建议appcompat-v7:21?
我在代码和菜单资源中使用android.support.v7.widget.SearchView.新的工具栏小部件有一个searchViewStyle,但我找不到一个参数来显示建议全宽(match_parent).
示例http://d0od.wpengine.netdna-cdn.com/wp-content/uploads/2014/07/material-makeover-4.jpeg
操作系统:openSUSE Tumbleweed 最新
正如堆栈文档所说,我可以使用 Tumbleweed 上默认存储库中的 zypper 安装堆栈。到 bin 的路径是/usr/bin/stack。
我遵循官方主页上的堆栈教程并执行stack new helloworld new-template(有效)。后cd进入文件夹,我想跑stack setup,但是这一次失败:
The GHC located at /usr/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /usr/bin/ghc /tmp/stack-sanity-check9034/Main.hs
-no-user-package-db in directory /tmp/stack-sanity-check9034/
exited with ExitFailure 1
/tmp/stack-sanity-check9034/Main.hs:1:8:
Could not find module ‘Distribution.Simple’
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
经过一番谷歌搜索后,我仍然不知道如何解决该错误。这就像我错过了一个非常基本的东西。
是否旁边Box用手工复制内部值一个语言功能向下RatedBox转换为Box?
type Box struct {
Name string
}
type RatedBox struct {
Box
Points int
}
func main() {
rated := RatedBox{Box: Box{Name: "foo"}, Points: 10}
box := Box(rated) // does not work
}
Run Code Online (Sandbox Code Playgroud)
// works, but is quite verbose for structs with more members
box := Box{Name: rated.Name}
Run Code Online (Sandbox Code Playgroud)