标签: builder

构建xib Interface Builder并将其作为子视图加载到iphone中

如果可以构建一个视图及其对应的xib文件,我想知道什么.然后,在通用控制器中,以编程方式加载此视图,并将其作为子视图添加到当前视图.

此子视图应作为通用信息框,可由许多控制器加载.

谢谢莱昂纳多

interface builder xib uiview addsubview

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

Kohana 3 - "查询"构建器提供0行

从phpmyadmin运行时,以下查询按预期返回一行.

SELECT units .  * , locations .  *
FROM units, locations
WHERE units.id = '1'
AND units.location_id = locations.id
LIMIT 0 , 30 
Run Code Online (Sandbox Code Playgroud)

但是当我尝试在Kohana 3中做到这一点时:

$unit = DB::select('units.*', 'locations.*')
->from('units', 'locations')
->where('units.id', '=', $id)->and_where('units.location_id', '=', 'locations.id')
->execute()->as_array();
var_dump($unit);
Run Code Online (Sandbox Code Playgroud)

它打印

数组(0){}

我究竟做错了什么?

php builder kohana kohana-3

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

如何使用Ruby Builder在XML标签中动态插入一些属性?

我正在使用Ruby Builder(http://builder.rubyforge.org/)从数据库动态生成XML文件。

要添加名称在变量中的标签,我找到了这个:xml.tag!(@ myTagName)

如何在此Tag中动态插入à属性列表?

  • 我不知道从数据库动态加载的属性的名称
  • 我需要创建一个循环,因为我不知道要插入多少个属性。

谢谢。

ruby xml builder

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

如何将函数应用于每个foreach结果?

我正在尝试创建一个非常简单的数据库驱动的块构建器,用于一些有趣的圣诞节编码.目前,我从数据库中以正确的顺序获取所有块,然后运行foreach循环遍历它们:

function get_blocks() {
    global $db;
    $GLOBALS['current_page_id'] = get_page_id();
    $stm = $db->prepare("SELECT * FROM page_blocks WHERE page_id = :id ORDER BY `block_order` ASC");
    $stm->execute(array(':id' => 1));
    $res = $stm->fetchAll();
    return $res;
}

$blocks = get_blocks();

foreach($blocks as $block) {
    if($block['block_name'] == 'block-type-1') {
        //code to execute
    }
}
Run Code Online (Sandbox Code Playgroud)

它可以工作,但我需要能够做的是将一个函数应用于每个块类似于(是的,我知道这不起作用):

foreach($blocks as have_block($block))
Run Code Online (Sandbox Code Playgroud)

有没有办法按顺序循环遍历数据库中的块,然后将函数应用于结果?

php foreach function block builder

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

禁用舞台按钮X.

我很快就到了,因为我没有一个非常流利的英语,对不起.

我正在学习javafx,我想在关闭后单击X的窗口时出现警告.我知道这是在我在窗口中间创建的按钮中执行此操作,但我不知道如何控制用户何时按X关闭程序.谢谢

java javafx builder scene

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

片段 getActivity() 中的 Android AlertDialog Builder 不起作用

我尝试在 Fragment 中构建 AlertDialog,但找不到 AlertDialog Builder 的正确上下文。

public class LoginFragment extends Fragment {
public LoginFragment() {
    // Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_login, container, false);

    Button btnEnter = (Button) rootView.findViewById(R.id.btnEnter);

    // Listening to register new account link
    btnEnter.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

        // if play name already exists
            AlertDialog dialog = new AlertDialog.Builder(getActivity())
                .setCancelable(false)
                .setIcon(R.drawable.login_icon)
                .setMessage("Player …
Run Code Online (Sandbox Code Playgroud)

android builder fragment android-alertdialog

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

实现构建器模式

我已经看到了两种实现构建器模式的流行方法:

// 1. The build() approach
Product p = builder.part1()
                   .part2()
                   .build();

// 2.The constructor approach
builder.part1()
       .part2();
Product p = new Product(builder);
Run Code Online (Sandbox Code Playgroud)

哪个更好?

java builder

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

如何使用 Fluent Builders Generator 等嵌套构建器在 Intellij 中生成构建器

因此,在使用 eclipse 时,我可以使用 Fluent Builders Generator 插件并获得创建嵌套构建器类的好处。

例如

public class a {

   private String aa;
   private B b;
} 

public class b {
   private String bb;
}
Run Code Online (Sandbox Code Playgroud)

在使用 a 类的插件构建器类创建时,我将能够使用以下内容:

 ABuilder().withAA("1").withBBuilder().withBB("2").build().build();
Run Code Online (Sandbox Code Playgroud)

inteliij 是否有任何插件可以生成这些类?我发现的唯一一件事是为两个类创建构建器并使用类似的东西:

 B bObject = BBuilder().withBB("1").build();
 ABuilder().withAA("1").withB(bObject).build();
Run Code Online (Sandbox Code Playgroud)

java eclipse builder intellij-idea

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

具有相同键不可变映射错误的多个条目

我有一个下面的构建器类,我从多线程应用程序中使用它,所以我使它成为线程安全的。为简单起见,我在这里只展示了几个字段来演示这个问题。

public final class ClientKey {
  private final long userId;
  private final int clientId;
  private final String processName;
  private final Map<String, String> parameterMap;

  private ClientKey(Builder builder) {
    this.userId = builder.userId;
    this.clientId = builder.clientId;
    this.processName = builder.processName;
    // initializing the required fields
    // and below line throws exception once I try to clone the `ClientKey` object
    builder.parameterMap.put("is_clientid", (clientId == 0) ? "false" : "true");
    this.parameterMap = builder.parameterMap.build();
  }

  public static class Builder {
    private final long userId;
    private final int clientId; …
Run Code Online (Sandbox Code Playgroud)

java multithreading builder builder-pattern guava

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

Lombok @Builder 继承同时为父母和孩子工作

我已经阅读了这篇关于将 lombok@Bulider与继承结合使用的文章https://reinhard.codes/2015/09/16/lomboks-builder-annotation-and-inheritance/ 一切正常。但在我的情况下,我还需要使用 builder for Parent class,而这种解决方法不起作用。

我也尝试添加@BuilderParent class但编译失败,因为Child class尝试覆盖builder()父级的方法。

        @AllArgsConstructor
        public class Parent {

            private final long a;
            private final long b;
            private final double c;
        }

        public class Child extends Parent{

            private final long aa;
            private final long bb;
            private final double cc;
            @Builder
            public Child(long a, long b, long c,
                        long aa, long bb, long cc)
                super(a,b,c);
                this.aa = aa;
                this.bb = bb;
                this.cc =cc; …
Run Code Online (Sandbox Code Playgroud)

java inheritance builder lombok

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