我可以通过curl执行以下命令成功创建一个地方:
$ curl -vX POST https://server/api/v1/places.json -d "
auth_token=B8dsbz4HExMskqUa6Qhn& \
place[name]=Fuelstation Central& \
place[city]=Grossbeeren& \
place[address]=Buschweg 1& \
place[latitude]=52.3601& \
place[longitude]=13.3332& \
place[washing]=true& \
place[founded_at_year]=2000& \
place[products][]=diesel& \
place[products][]=benzin \
"
Run Code Online (Sandbox Code Playgroud)
服务器返回HTTP/1.1 201 Created.
现在我想将有效负载存储在JSON文件中,如下所示:
// testplace.json
{
"auth_token" : "B8dsbz4HExMskqUa6Qhn",
"name" : "Fuelstation Central",
"city" : "Grossbeeren",
"address" : "Buschweg 1",
"latitude" : 52.3601,
"longitude" : 13.3332,
"washing" : true,
"founded_at_year" : 2000,
"products" : ["diesel","benzin"]
}
Run Code Online (Sandbox Code Playgroud)
所以我修改了要执行的命令,如下所示:
$ curl -vX POST http://server/api/v1/places.json -d @testplace.json …Run Code Online (Sandbox Code Playgroud) 当使用导航抽屉时,Android开发人员建议在ActionBar中"只有那些在导航抽屉中表示的屏幕应该实际上具有导航抽屉图像",并且"所有其他屏幕都具有传统的向上克拉".
详情请见:http://youtu.be/F5COhlbpIbY
我正在使用一个活动来控制多个级别的片段,并且可以使导航抽屉图像在所有级别上显示和运行.
创建较低级别的片段时,我可以调用ActionBarDrawerToggle setDrawerIndicatorEnabled(false)隐藏导航抽屉图像并显示向上插入符号
LowerLevelFragment lowFrag = new LowerLevelFragment();
//disable the toggle menu and show up carat
theDrawerToggle.setDrawerIndicatorEnabled(false);
getSupportFragmentManager().beginTransaction().replace(R.id.frag_layout,
lowFrag, "lowerFrag").addToBackStack(null).commit();
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是当我导航回到最高级别的片段时,向上克拉仍然显示而不是原始的导航抽屉图像.有关如何"刷新"顶级片段上的ActionBar以重新显示导航抽屉图像的任何建议?
汤姆的建议对我有用.这是我做的:
此活动控制应用程序中的所有片段.
在准备新片段以替换其他片段时,我将DrawerToggle设置为setDrawerIndicatorEnabled(false):
LowerLevelFragment lowFrag = new LowerLevelFragment();
//disable the toggle menu and show up carat
theDrawerToggle.setDrawerIndicatorEnabled(false);
getSupportFragmentManager().beginTransaction().replace(R.id.frag_layout,
lowFrag).addToBackStack(null).commit();
Run Code Online (Sandbox Code Playgroud)
接下来,在覆盖中onBackPressed,我通过将DrawerToggle设置为这样来恢复上面的内容setDrawerIndicatorEnabled(true):
@Override
public void onBackPressed() {
super.onBackPressed();
// turn on the Navigation Drawer image;
// this is called in the LowerLevelFragments
setDrawerIndicatorEnabled(true)
}
Run Code Online (Sandbox Code Playgroud)
在我修改过的片段中onCreate, …
android android-fragments android-actionbar navigation-drawer
我想用pgadmin客户端管理我的heroku数据库.到现在为止,我一直在这样做psql.当我使用来自heroku pg:credentials连接de DB的数据时pgadmin,我获得:
发生了错误:
连接到服务器时出错:致命错误:数据库"postgres"权限被拒绝详细信息:用户没有CONNECT权限.
有关如何实现连接的任何指南?
你什么时候在RxJava中使用map vs flatMap?
比方说,我们想将包含JSON的文件映射到包含JSON的字符串中 -
使用map,我们必须以某种方式处理Exception.但是如何?:
Observable.from(jsonFile).map(new Func1<File, String>() {
@Override public String call(File file) {
try {
return new Gson().toJson(new FileReader(file), Object.class);
} catch (FileNotFoundException e) {
// So Exception. What to do ?
}
return null; // Not good :(
}
});
Run Code Online (Sandbox Code Playgroud)
使用flatMap,它更加冗长,但我们可以将问题转发到Observables链中,如果我们选择其他地方甚至重试,则可以处理错误:
Observable.from(jsonFile).flatMap(new Func1<File, Observable<String>>() {
@Override public Observable<String> call(final File file) {
return Observable.create(new Observable.OnSubscribe<String>() {
@Override public void call(Subscriber<? super String> subscriber) {
try {
String json = new Gson().toJson(new FileReader(file), Object.class);
subscriber.onNext(json);
subscriber.onCompleted();
} …Run Code Online (Sandbox Code Playgroud) 该LayoutInflater.inflate文档是不看好的目的十分清楚我的attachToRoot参数.
attachToRoot:膨胀的层次结构是否应附加到根参数?如果为false,则root仅用于为XML中的根视图创建LayoutParams的正确子类.
有人可以更详细地解释,特别是根视图是什么,并且可能显示一个行为true和false值之间的变化的例子?
我放在setHasOptionsMenu(true)里面onCreateView,但我仍然无法调用onCreateOptionsMenu内部碎片.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
return inflater.inflate(R.layout.facesheet, container, false);
}
Run Code Online (Sandbox Code Playgroud)
以下是我的onCreateOptionsMenu代码.
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
getSupportMenuInflater().inflate(R.menu.layout, menu);
return (super.onCreateOptionsMenu(menu));
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误消息:
该方法
onCreateOptionsMenu(Menu)类型片段的必须重写或实现的超类型方法.
android android-fragments layout-inflater oncreateoptionsmenu
Django的(1.5)是干活的对我很好,但是当我火了Python解释器(Python 3中),检查一些东西,我得到当我尝试导入最奇怪的错误- from django.contrib.auth.models import User-
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/django/conf/__init__.py", line 36, in _setup
settings_module = os.environ[ENVIRONMENT_VARIABLE]
File "/usr/lib/python3.2/os.py", line 450, in __getitem__
value = self._data[self.encodekey(key)]
KeyError: b'DJANGO_SETTINGS_MODULE'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/django/contrib/auth/models.py", line 8, in <module>
from django.db import models
File "/usr/local/lib/python3.2/dist-packages/django/db/__init__.py", line 11, in <module>
if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/usr/local/lib/python3.2/dist-packages/django/conf/__init__.py", line 52, in …Run Code Online (Sandbox Code Playgroud) 我在Android SDK中看过AccountManager,它用于存储帐户信息.因此,我找不到任何关于其目的的一般性讨论.有谁知道有关AccountManager背后的意图以及它为您购买的内容的任何有用的讨论?对于哪种类型的账户适合的任何意见?这是您将用户的帐户信息用于一般Web服务的位置吗?
我一直试图让ActionBarSherlock工作并遇到一些问题.我遇到的一个问题是在尝试构建它时出现以下消息:
Plugin with id 'android-library' not found
Run Code Online (Sandbox Code Playgroud)
特别:
D:\Projects\Android\actionbarsherlock>D:\Projects\Android\gradlew --info build
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file
'D:\Projects\Android\actionbarsherlock\build.gradle'.
Included projects: [root project 'actionbarsherlock']
Evaluating root project 'actionbarsherlock' using build file
'D:\Projects\Android\actionbarsherlock\build.gradle'.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\Projects\Android\actionbarsherlock\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating root project 'actionbarsherlock'.
> Plugin with id 'android-library' not found.
Run Code Online (Sandbox Code Playgroud)
我把它视为一个单独的线程中的ABS问题,所以在这里我很好奇如何解决一般问题:
Plugin with id 'android-library' not found
Run Code Online (Sandbox Code Playgroud)
这是build.gradle:
apply …Run Code Online (Sandbox Code Playgroud) android ×4
android-view ×1
build.gradle ×1
curl ×1
database ×1
django ×1
flatmap ×1
git ×1
git-fetch ×1
git-remote ×1
gradle ×1
gradlew ×1
heroku ×1
java ×1
json ×1
mapping ×1
pgadmin ×1
postgresql ×1
python ×1
rx-java ×1