小编Jef*_*ado的帖子

Android如何从代码向另一个LinearLayout添加Linearlayout

我在main.xml中有一个LinearLayout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:id="@+id/mainLayout" >

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我制作了另一个XML文件,称为item_box.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/item_bg"
    android:gravity="right" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon" />

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginRight="20dp"
        android:text="@string/item1"
        android:textSize="30dp" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginRight="20dp"
        android:gravity="right"
        android:text="@string/number1"
        android:textColor="@color/number_bg"
        android:textSize="30dp" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

基本上,我想从代码中(以编程方式)执行的操作是将几个item_box.xml添加到main.xml中。我该怎么做?

java android android-linearlayout

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

Java Swing Card Layout更改显示的面板?

所以我有一个面板的jFrame.在该面板内部还有两个面板,布局设置为卡片.在这两个面板中的一个面板上有一个按钮.如何更改按下该按钮时显示的面板?

java layout swing panel

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

以编程方式创建属性集和属性

我正在使用以下链接中列出的代码:

http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/programmatically_adding_attributes_and_attribute_sets

一切正常,直到这一点:

    // Just add a default group.
    else
    {
        $this->logInfo("Creating default group [{$this->groupName}] for set.");

        $modelGroup = Mage::getModel('eav/entity_attribute_group');
        $modelGroup->setAttributeGroupName($this->groupName);
        $modelGroup->setAttributeSetId($id);

        // This is optional, and just a sorting index in the case of
        // multiple groups.
        // $modelGroup->setSortOrder(1);

        $model->setGroups(array($modelGroup));
    }
Run Code Online (Sandbox Code Playgroud)

我不确定在哪里需要设置对象引用 - 我试图将其作为一个可以自动化的单独文件 - 我正在运行此文件

require_once 'app/Mage.php'; 
Mage::app(); 
Run Code Online (Sandbox Code Playgroud)

任何帮助都将非常感谢

attributes magento

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

如何用jq将json文档中的空值替换为特定值?

我有一个包含的json文件 nulls as values for some keys, which I would like to replace with some specific value.

鉴于此输入:

{
  "id": null,
  "rows": [
    {
      "panels": [
        {
          "title": "Panel1",
          "datasource": null
        },
        {
          "title": "Panel2",
          "datasource": null
        }
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

我想拥有

{
  "id": null,
  "rows": [
    {
      "panels": [
        {
          "title": "Panel1",
          "datasource": "mydb"
        },
        {
          "title": "Panel2",
          "datasource": "mydb"
        }
        ]
     }
  ]
}
Run Code Online (Sandbox Code Playgroud)

What I currently use is

sed 's/"datasource": null/"datasource": "mydb"/'
Run Code Online (Sandbox Code Playgroud)

This produces the …

json jq

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

如何使用 jq 将 json 部分添加到现有文件

我正在使用它jq来解析 JSON 文件。我有 JSON 文件的某些部分,内容如下

[
  {
    "PropagateAtLaunch": true,
    "Value": {
      "Ref": "TNAM"
    },
    "Key": "Name"
  },
  {
    "PropagateAtLaunch": true,
    "Value": {
      "Ref": "TAPP"
    },
    "Key": "application"
  },
  {
    "PropagateAtLaunch": true,
    "Value": {
      "Ref": "TENV"
    },
    "Key": "environment"
  },
  {
    "PropagateAtLaunch": true,
    "Value": {
      "Ref": "TSHA"
    },
    "Key": "shared"
  },
  {
    "PropagateAtLaunch": true,
    "Value": {
      "Ref": "TTER"
    },
    "Key": "tier"
  },
  {
    "PropagateAtLaunch": true,
    "Value": {
      "Ref": "CostCenter"
    },
    "Key": "cost-center"
  }
]
Run Code Online (Sandbox Code Playgroud)

在此我想添加另一个部分,例如:

{
  "Value": {
    "Ref": …
Run Code Online (Sandbox Code Playgroud)

bash jq

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

Visual Studio代码上的Python 3

所以我一直在网上试图找到如何在visual studio代码上使用python 3编译我的python程序.但是,似乎他们没有太多关于如何做的信息.下面是我的task.json文件的样子.我在做什么吗?

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "Python",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}
Run Code Online (Sandbox Code Playgroud)

任何建议都会非常感谢你

python python-3.x visual-studio-code

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

弹跳卡算法

对于像你在单人纸牌游戏中看到的"弹跳牌"一样,有什么好的算法?

你看过最酷的卡片动画是什么?

编辑 - 除了Windows游戏之外还有什么?

animation

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

使用xlinq有效地"深入"到XML树中?

我正在编写一个程序来解析一些第三方XML文件.结构就像......

<CharacterSheet>
    ...
    <StatBlock>
        ...
        <Stat>
            ...
            <alias />
            ...
        </Stat>
        ...
    </StatBlock>
    ...
</CharacterSheet>
Run Code Online (Sandbox Code Playgroud)

我正在使用它来使用linq进行一些练习,我正在罚款我必须编写一些非常丑陋的链式查询来获得我想要的,统计列表及其所有别名.

var CharSheet = from i in character.Elements()
        where i.Name == "CharacterSheet"
        select i;

var StatBlocks = from sheet in CharSheet
         from statBlock in sheet.Elements()
         where statBlock.Name == "StatBlock"
         select statBlock;

var stats = from statBlock in StatBlocks
        from stat in statBlock.Elements()
        select stat;

var statAliases = from stat in stats
          from alias in stat.Elements()
          where alias.Name == "alias"
          select new { stat, alias }; …
Run Code Online (Sandbox Code Playgroud)

c# xml linq linq-to-xml

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

查找字符串中字符的位置

我有一个字符串:"fdfdfd.dfdfd.dfdfdf.dfdfdf".我想得到最后一个点的位置.我试过这个:

Index = re.search(r"\w + '.' \w+$", string)
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我怎样才能做到这一点?

python string

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

我想建立一个歌曲识别网站

我正在考虑建立一个歌曲识别网站(类似于midomi.com,但更简单):

用户上传MP3或发布Youtube视频的链接,网站将告诉他(免费)曲目,艺术家和其他信息的名称 - 基本上所有应该在MP3的ID3标签中的东西.

最大的问题是我该如何识别这首歌?我不打算自己编写算法(我不能花很多时间在我想要免费提供的东西上:-)).

我知道,例如Winamp使用Gracenote数据库http://www.gracenote.com/进行MP3识别.您是否可以使用PHP执行相同操作 - 通过调用一些远程方法来搜索数据库以查找与提供的文件或其"足迹"匹配的内容?

或者您可以建议任何其他数据库或工具吗?

我发现有人在PHP中使用了Gracenote:http://www.phpfreaks.com/forums/index.php?topic = 240930.0 但这基本上只是编辑标签中的文本.歌曲识别怎么样?

php database

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