我现在已经阅读和研究了大约3天.这是我的最后一招.
land.rb:
has_many :uploads , :dependent => :destroy
accepts_nested_attributes_for :uploads, :allow_destroy => true,:reject_if => :all_blank
Run Code Online (Sandbox Code Playgroud)
upload.rb
belongs_to :land
Run Code Online (Sandbox Code Playgroud)
_land_form_partial.html.erb
<%= form_for land , :html => {:multipart => true} do |f| %>
<%= f.fields_for :uploads do |builder| %>
<div class="land_fields">
<%= builder.label :filename, "Image" %>
<%= builder.text_field :filename %> <br/>
Delete: <%= builder.check_box :_destroy %>
</div>
<% end %>
#... buttons and other fields
<% end %>
Run Code Online (Sandbox Code Playgroud)
lands_controller.rb
def update
if @land.update_attributes(land_params)
flash[:success] = "Land updated"
redirect_to lands_path
else
flash[:alert] = …Run Code Online (Sandbox Code Playgroud) 如何增加Xcode中线条之间的距离?我的意思是在实际的代码中.
即使我在Xcode首选项中更改字体和字体大小,代码行仍然太靠近而且非常烦人.
我的Android Manifest文件
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我没有任何其他接收器.
测试:
~/development/sdk/platform-tools $ ./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.myapp.myapplication/com.google.android.gms.analytics.CampaignTrackingService --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"
Run Code Online (Sandbox Code Playgroud)
响应:
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.myapp.myapplication/com.google.android.gms.analytics.CampaignTrackingService (has extras) }
Broadcast completed: result=0
Run Code Online (Sandbox Code Playgroud)
现在,当我运行应用程序时,我得到了 I/GAV3(17797): Thread[GAThread,5,main]: No campaign data found.
然后我尝试了自定义接收器:这是我的代码:
<service android:name="com.myapp.myapplication.ReferrerCatcher"/>
<receiver android:name="com.myapp.myapplication.ReferrerCatcher" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我的接收器:
package com.myapp.myapplication;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.google.analytics.tracking.android.CampaignTrackingReceiver;
public class ReferrerCatcher extends …Run Code Online (Sandbox Code Playgroud) android google-analytics broadcastreceiver android-intent google-play
正如您猜测一切正常,没有触发点击事件.在我开始之前,我已经阅读了很多有关此事的帖子,但是对于我的生活,我无法弄明白.这是代码.
activity_main.xml(调用列表的主要布局)
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
list_mainsegments_row.xml(自定义行)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/iconView"
style="@style/generalPagesLogoStyle"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_margin="@dimen/tendpPadding"
android:scaleType="fitCenter"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/titleMainSegments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_weight="0.5"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@dimen/generalTextSize"
/>
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:scaleType="fitCenter"
android:src="@drawable/arrow" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
MyAdapter.java
public class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, int resource, int textViewResourceId,
String[] strings) {
super(context, resource, textViewResourceId, strings);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) …Run Code Online (Sandbox Code Playgroud) 我需要更新我的Asset表,所以我需要做这样的事情。
from(a in Asset,
where: a.id == ^asset.id,
update: [set: [asset_name: "a name"] ]
)
|> Repo.update_all([])
Run Code Online (Sandbox Code Playgroud)
这工作正常,但updated_at没有更新。
从文档中:
请记住,此 update_all 不会更新自动生成的字段,例如 Updated_at 列。
那么这是否意味着我需要将时间传递到查询中?就像是DateTime.utc_now
谢谢
我有一个 SharedModule
import { NgModule } from '@angular/core';
import { ControlMessagesComponent } from './control-messages.component';
@NgModule({
imports: [
],
declarations: [
ControlMessagesComponent
],
exports: [
ControlMessagesComponent,
]
})
export class SharedModule {}
Run Code Online (Sandbox Code Playgroud)
然后我导入了2个不同的模块:
import { SharedModule } from './../shared/shared.module';
@NgModule({
imports: [
SharedModule
],
declarations: [
],
providers: [
]
})
export class OnboardModule {}
import { SharedModule } from '../shared/shared.module';
@NgModule({
imports: [
SharedModule
],
declarations: [
],
providers: [
]
})
export class AModule {}
Run Code Online (Sandbox Code Playgroud)
这里是 ControlMessagesComponent
import { …Run Code Online (Sandbox Code Playgroud) 我不明白这个错误,我搜索了很多。没有一个例子显示多重关联?这是代码。
我的访问列表:
defmodule Db.AccessList do
use Ecto.Schema
schema "access_lists" do
belongs_to :user_id, Db.User
belongs_to :role_id, Db.Role
belongs_to :asset_id, Db.Asset
belongs_to :project_id, Db.Project
timestamps()
end
def changeset(model, params \\ %{}) do
model
|> Ecto.Changeset.cast(params, [:user_id, :role_id, :asset_id, :project_id])
|> Ecto.Changeset.validate_required([:user_id, :role_id])
end
end
Run Code Online (Sandbox Code Playgroud)
测试:
defmodule AccessListTest do
alias Db.{ AccessList }
use ExUnit.Case
@valid_attr %{user_id: 1, role_id: 1, asset_id: 1, project_id: 1 }
@tag :wip
test "ACCESSLIST.1 valid attribute" do
changeset = AccessList.changeset(%AccessList{}, @valid_attr)
assert changeset.valid?
end
@tag :wip
test "ACCESSLIST.2 …Run Code Online (Sandbox Code Playgroud) 请检查这个小提琴:http: //jsfiddle.net/kgXRa/
这是代码(在JSFiddle中实现)
var app = angular.module('myApp', []);
app.controller('MyCtrl', ['$scope', function ($scope) {
$scope.field = [];
$scope.value = [];
$scope.inputCounter = 0;
}]);
app.directive('addInput', ['$compile', function ($compile) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.find('button').bind('click', function () {
var input = angular.element('<div><input type="text" ng-model="field[' + scope.inputCounter + ']"><input type="text" ng-model="value[' + scope.inputCounter + ']"> <a href="javascript:;" ng-click="remove_it(' + scope.inputCounter + ')">remove</a></div> ');
var compile = $compile(input)(scope);
element.append(input);
scope.inputCounter++;
scope.remove_it = function(scope_counter) {
compile.remove(this);
scope.inputCounter--; …Run Code Online (Sandbox Code Playgroud) 这是我的数组:
sorted_array = [["Friday", "42", 8], ["Friday", "34", 8], ["Friday", "41", 78], ["Friday", "35", 7], ["Friday", "40", 7], ["Friday", "36", 6], ["Friday", "39", 7], ["Friday", "37", 56], ["Friday", "38", 6], ["Monday", "38", 3], ["Monday", "39", 5], ["Monday", "37", 54], ["Monday", "40", 6], ["Monday", "36", 6], ["Monday", "41", 7], ["Monday", "35", 7], ["Monday", "42", 7], ["Monday", "34", 8]]
Run Code Online (Sandbox Code Playgroud)
我需要做:
{ 'Friday' => [ ["42", 8], ["34", 8], ["41", 78], ["35", 7], [ "40", 7], ["36", 6], [ "39", 7], ["37", 56], …Run Code Online (Sandbox Code Playgroud) 我一直试图WeakReference在我的Android项目中使用,但我从来没有取得任何成功.现在我真的需要它,因为我正在处理旧设备,我必须尽可能地保持内存清洁.
无论如何,我有一个数组,其中包含大约1000个不同字符串列表.我需要加载它,然后在其中找到一个字符串.
这就是我目前使用它的方式:
String[] campaignList = context.getResources().getStringArray(R.array.campaignList);
WeakReference<String[]> weakCampaignList = new WeakReference<String[]>(campaignList);
Run Code Online (Sandbox Code Playgroud)
这是正确的使用方式WeakReference吗?如果是,那么我不明白的是阵列正在水合,String[]然后我把它传递给了WeakReference.那么这是不是意味着我在分配给一个阵列的内存上有2个点?或者我完全误解了这个WeakReference概念?
我在所有资源中发现的一个非常好的资源就是这个:
http://neverfear.org/blog/view/150/Strong_Soft_Weak_and_Phantom_References_Java
编辑:
我的代码没有问题.只需要知道我在性能方面是否正确.
for (int i = 0; i < weakCampaignList.get().length; i++) {
Log.d(TAG,"weakCampaignList: "+weakCampaignList.get()[i]);
}
Run Code Online (Sandbox Code Playgroud)
我的整个方法
public static String getTheCampaign(String country, Context context) {
String campaign = "";
campaign = "annual_subscription_" + country;
String[] campaignList = context.getResources().getStringArray(
R.array.campaign_list);
ArrayList<WeakReference<String>> weakCampaignList = new ArrayList<WeakReference<String>>();
for (String s : campaignList) {
weakCampaignList.add(new WeakReference<String>(s));
}
if (country.equals("") || …Run Code Online (Sandbox Code Playgroud) android ×2
ecto ×2
elixir ×2
ruby ×2
angular ×1
angularjs ×1
arrays ×1
dynamicform ×1
forms ×1
google-play ×1
hash ×1
java ×1
jquery ×1
listadapter ×1
listview ×1
performance ×1
typescript ×1
xcode ×1
xcode4 ×1