我有一个列表活动,其项目由图像+文本组成.我需要允许用户更改视图并使用gridview而不是它(其元素仍然由相同的图像+文本组成).
用户可以通过图标菜单完成:
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId()== R.id.change_view)
{
// ?
}
}
Run Code Online (Sandbox Code Playgroud)
我试图设置新的适配器(见下文),但它不起作用..我必须创建一个新的活动来做到这一点?
if(item.getItemId()== R.id.change_view)
{
setContentView(R.layout.grid_view);
gridViewAdapter = new GridViewAdapter(this,R.layout.bookmark_list_item,MyApp.getItems().findAll());
list.setAdapter(gridViewAdapter);
list.setVisibility(View.VISIBLE);
}
Run Code Online (Sandbox Code Playgroud) 我已经写了一个docker-compose.yml
文件来创建一个带有nodejs和mongodb的多容器应用程序(所以有两个容器),我想让一些选项可配置,作为服务器地址和端口的选择.为此,我在docker-compose.yml中编写了以下内容,将它们设置为env变量:
..
web:
environment:
- PORT=3000
- ADDRESS=xxx.xxx.xxx.xxx
..
Run Code Online (Sandbox Code Playgroud)
在我的应用程序的源代码中,我使用process.env.PORT
和process.env.ADDRESS
引用这些变量.
但是,如果我想更改这些值,我该怎么办PORT=3001
?例如,设置?我必须再次使用docker-compose build
并docker-compose up
构建所有应用程序,包括mongodb容器?
我有一个任务对页面执行GET请求.响应的正文是JSON,如下所示.
{
"ips": [
{
"organization": "1233124121",
"reverse": null,
"id": "1321411312",
"server": {
"id": "1321411",
"name": "name1"
},
"address": "x.x.x.x"
},
{
"organization": "2398479823",
"reverse": null,
"id": "2418209841",
"server": {
"id": "234979823",
"name": "name2"
},
"address": "x.x.x.x"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想提取字段ID和地址,并尝试(对于id字段):
tasks:
- name: get request
uri:
url: "https://myurl.com/ips"
method: GET
return_content: yes
status_code: 200
headers:
Content-Type: "application/json"
X-Auth-Token: "0010101010"
body_format: json
register: json_response
- name: copy ip_json content into a file
copy: content={{json_response.json.ips.id}} dest="/dest_path/json_response.txt"
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
字段'args'具有无效值,该值似乎包含未定义的变量.错误是:'list object'没有属性'id'..
问题出在哪儿?
我有一个名为launch db
with --net=host
option 的Couchbase服务器容器,它公开了端口11210,现在我必须将另一个容器链接到该容器。如果--link
在运行新容器时使用该选项,则键入:
docker run -d -P --name my_name --link db:db my_image
Run Code Online (Sandbox Code Playgroud)
我得到:
来自守护程序的错误响应:冲突选项:主机类型网络不能与链接一起使用。这将导致不确定的行为。
我该如何解决?
我有一个运行端口映射4000:8080的cadvisor,我必须将它与一个带有prometheus的容器连接起来.
我的prometheus.yml是:
scrape_configs:
# Scrape Prometheus itself every 2 seconds.
- job_name: 'prometheus'
scrape_interval: 2s
target_groups:
- targets: ['localhost:9090', 'cadvisor:8080']
Run Code Online (Sandbox Code Playgroud)
此文件具有路径/home/test/prometheus.yml.为了用prometheus运行容器,我做:
docker run -d -p 42047:9090 --name=prometheus -v /home/test/prometheus.yml:/etc/prometheus/prometheus.yml --link cadvisor:cadvisor prom/prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000
Run Code Online (Sandbox Code Playgroud)
容器已创建,但会立即死亡.你能告诉我问题出在哪里吗?
消息形式docker events&
:
2016-11-21T11:43:04.922819454+01:00 container start 69d03c68525c5955cc40757dc973073403b13fdd41c7533f43b7238191088a25 (image=prom/prometheus, name=prometheus)
2016-11-21T11:43:05.152141981+01:00 container die 69d03c68525c5955cc40757dc973073403b13fdd41c7533f43b7238191088a25 (exitCode=1, image=prom/prometheus, name=prometheus)
Run Code Online (Sandbox Code Playgroud) 如果我有这些结构:
struct rec {
int key;
double value;
};
struct node {
struct rec record;
struct node *next;
};
Run Code Online (Sandbox Code Playgroud)
我必须将项目的字段值复制 struct rec *r
到项目中struct node *n
,
我可以这样做吗?
n->record.key = r->key;
n->record.value = r->value;
Run Code Online (Sandbox Code Playgroud) LR(1)解析器可以解析这种类型的语法吗?
S -> SA | A
A -> aSb | ab
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写一个实现这种类型解析器的Java程序,但是我只能在没有左递归的语法上得到正确的结果.
我有一个postgres:9.5.6-alpine容器,另一个名为web的容器,必须链接到它.我想在启动后运行create_db.sh
postgres容器中命名的脚本并执行docker-entrypoint.sh,以便创建数据库和用户并恢复备份.我docker-compose.yml
(postgres部分):
postgres:
build: ./postgres
container_name: postgres
volumes:
- /shared_folder/postgresql:/var/lib/postgresql
ports:
- "5432:5432"
command: sh /home/create_db.sh
Run Code Online (Sandbox Code Playgroud)
内容create_db.sh
是:
#!/bin/sh
psql -d template1 -U postgres
psql --command "CREATE USER user WITH PASSWORD 'userpassword';"
psql --command "CREATE DATABASE userdb;"
psql --command "GRANT ALL PRIVILEGES ON DATABASE userdb to user;"
psql --command "\q;"
psql -U user -d userdb -f /var/lib/postgresql/backup.sql
exit
Run Code Online (Sandbox Code Playgroud)
当我跑docker-compose build
,然后docker-compose up
我得到这个:
Attaching to postgres, web
postgres | psql: could not connect to …
Run Code Online (Sandbox Code Playgroud) 我有这两个班:
public class Superclass
{
public Superclass();
...
}
Run Code Online (Sandbox Code Playgroud)
和
public class ChildClass extends Superclass
{
public ChildClass();
public setname(String name)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
如果我这样做:
Superclass a;
a = new ChildClass();
a.setname("Roger");
Run Code Online (Sandbox Code Playgroud)
我收到此警告:方法setname(String)未定义类型Superclass.怎么解决?谢谢
我想在装有 Ubuntu 16.04 的远程计算机上安装 Docker,使用 Ansible 并遵循https://docs.docker.com/engine/installation/linux/ubuntu/上的官方文档。一切似乎都有效,直到 ansible 到达名称为“install Docker”的任务,我得到“没有可用的与‘docker-ce’匹配的包”。
剧本的以下部分,从设置存储库的点开始:
- name: set the stable repository
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable
- name: Update all packages to the latest version
apt:
upgrade: dist
- name: install Docker
apt:
name: docker-ce
state: present
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢?
这样做时,我收到此错误:
The return type is incompatible with MouseAdapter.mouseClicked(MouseEvent)
Run Code Online (Sandbox Code Playgroud)
类:
public class MyMouseAdapter extends MouseAdapter
{
public MyMouseAdapter()
{
// TODO Auto-generated constructor stub
}
@Override
public String mouseClicked(MouseEvent e)
{
// TODO Auto-generated method stub
}
}
Run Code Online (Sandbox Code Playgroud)
哪里错了?原来的方法是public void mouseClicked(MouseEvent e)
docker ×5
ansible ×2
java ×2
parsing ×2
android ×1
c ×1
cadvisor ×1
containers ×1
couchbase ×1
gridview ×1
inheritance ×1
json ×1
listview ×1
lr-grammar ×1
postgresql ×1
prometheus ×1
structure ×1
swing ×1