我已经阅读了维基百科上关于过程式编程和函数式编程的文章,但我还是有点困惑。有人能把它归结为核心吗?

我正在使用一个自定义的动作栏视图,正如你在下面的截图中看到的,在动作栏中有一个空白的灰色空间。我想把它去掉。

我做了什么?

res / values-v11 / styles.xml

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
        <item name="actionBarStyle">@style/ActionBarStyle</item>
</style>

res /价值/ my_custom_actionbar.xml

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="android:height">60dp</item>
    </style>
</resources>

清单

<uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="19" />

<application
            android:icon="@drawable/ic_launcher"
            android:label="@string/AppName"
            android:theme="@style/AppBaseTheme" >
    <!-- activities... etc -->
</application>

MainActivity

public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    ActionBar actionbar = getSupportActionBar();

    actionbar.setDefaultDisplayHomeAsUpEnabled(false);
    actionbar.setDisplayHomeAsUpEnabled(false);
    actionbar.setDisplayShowCustomEnabled(true);
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setDisplayShowTitleEnabled(false);
    actionbar.setDisplayUseLogoEnabled(false);
    actionbar.setHomeButtonEnabled(false);

    // Add the custom layout
    View view = LayoutInflater.from(this).inflate(R.layout.actionbar, null, false);
    actionbar.setCustomView(view);
}

我发现了一个最近的帖子,指出有一个问题与最新发布。我也更新了ADT和SDK到Android 5。

Android ActionBar的自定义视图不填充父元素

我不知道该怎么办。

编辑(部分解决方案):

不能在Android上工作<= API 10。

Android棒棒糖,AppCompat ActionBar自定义视图不占用整个屏幕宽度

我改变了什么:

使用最新sdk版本:

<uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="21" />

添加一个toolbarStyle:

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
        <item name="actionBarStyle">@style/ActionBarStyle</item>

        <item name="android:toolbarStyle">@style/ToolbarStyle</item>
        <item name="toolbarStyle">@style/ToolbarStyle</item>
</style>

<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
    <item name="contentInsetStart">0dp</item>
    <item name="android:contentInsetStart">0dp</item>
</style>

我正在尝试实现谷歌几天前发布的新的ActionBar支持库。在过去,我已经成功地实现了ActionBarSherlock没有任何问题使用相同的方法在谷歌开发人员的支持库设置页面上列出-使用关于如何包括资源的指南(这是类似于ActionBarSherlock是如何做到的)。我把这个库项目作为库加载到我自己的项目中。

我能看出图书馆的资料还不错。当,而不是在我的MainActivity.java上扩展活动,我把它改为扩展ActionBarActivity(根据谷歌的指令),没有发生错误-它正确地导入。

我甚至尝试绕过style.xml文件,添加@style/Theme.AppCompat。光直接在AndroidManifest.xml的<应用>和<活动>与android:theme="@style/ThemeAppCompat。所有的尝试都会导致同样的错误。

现在的问题是我不能让它改变主题,更不用说在不抛出错误的情况下构建了。下面是我收到的错误,后面是我更改为使用新主题的style.xml文件。

我有一定的Android应用程序工作经验,正在运行Eclipse的最新版本的支持库和SDK编译API 18 (Android 4.3)。

生成时收到的错误

获取父项的错误:没有找到匹配给定名称的资源'@style/Theme.AppCompat.Light'。styles.xml /ActBarTest/res/values line 3 Android AAPT Problem

style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.ProsoftStudio.ACTest" parent="@style/Theme.AppCompat.Light">
    </style>
</resources>

有什么建议吗?这从来不是ActionBarSherlock的问题。我想使用这个新的支持库。看起来像是.jar在加载,而不是资源。

我最近发现了FP错误(试图学习Haskell),到目前为止,我对我所看到的(一流函数、惰性求值和所有其他好东西)印象深刻。我还不是专家,但我已经开始发现对基本算法进行“功能性”推理比命令式推理更容易(而且我很难回到我必须回到的地方)。

The one area where current FP seems to fall flat, however, is GUI programming. The Haskell approach seems to be to just wrap imperative GUI toolkits (such as GTK+ or wxWidgets) and to use "do" blocks to simulate an imperative style. I haven't used F#, but my understanding is that it does something similar using OOP with .NET classes. Obviously, there's a good reason for this--current GUI programming is all about IO and side effects, so purely functional programming isn't possible with most current frameworks.

My question is, is it possible to have a functional approach to GUI programming? I'm having trouble imagining what this would look like in practice. Does anyone know of any frameworks, experimental or otherwise, that try this sort of thing (or even any frameworks that are designed from the ground up for a functional language)? Or is the solution to just use a hybrid approach, with OOP for the GUI parts and FP for the logic? (I'm just asking out of curiosity--I'd love to think that FP is "the future," but GUI programming seems like a pretty large hole to fill.)

在Java中设计并发线程时,使用Runnable接口和Callable接口有什么区别,为什么你会选择其中一个而不是另一个?

我正在应用程序中从ActionBar迁移到工具栏。 但我不知道如何显示和设置单击事件在工具栏上的后退箭头,就像我在动作栏上做的那样。

使用ActionBar,我调用mActionbar.setDisplayHomeAsUpEnabled(true)。 但是没有类似的方法。

有没有人遇到过这种情况,并以某种方式找到了解决它的方法?

从我在Java中使用线程的时间来看,我发现了两种编写线程的方法:

使用可运行的机具:

public class MyRunnable implements Runnable {
    public void run() {
        //Code
    }
}
//Started with a "new Thread(new MyRunnable()).start()" call

或者,使用扩展线程:

public class MyThread extends Thread {
    public MyThread() {
        super("MyThread");
    }
    public void run() {
        //Code
    }
}
//Started with a "new MyThread().start()" call

这两个代码块有什么显著的区别吗?