我有一个NSURLSession调用dataTaskWithRequest以便以这种方式发送POST请求
func makeRequest(parameters: String, url:String){
var postData:NSData = parameters.dataUsingEncoding(NSASCIIStringEncoding)!
var postLength:NSString = String(postData.length )
var request = NSMutableURLRequest(URL: NSURL(string: url)!)
var session = NSURLSession.sharedSession()
request.HTTPMethod = "POST"
var error:NSError?
//request.HTTPBody = NSJSONSerialization.dataWithJSONObject(postData, options: nil, error: &error)
request.HTTPBody = postData
request.setValue(postLength, forHTTPHeaderField: "Content-Length")
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.setValue("application/json", forHTTPHeaderField: "Accept")
var task = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
println("Response:\(response)")
// Other stuff goes here
})
Run Code Online (Sandbox Code Playgroud)
响应等于:
<NSHTTPURLResponse: 0x7fcd205d0a00> { URL: http://XXX.XXX.XXX:0000/*** } { status code: 200, headers { …Run Code Online (Sandbox Code Playgroud) 将我的Mac更新到OS X El Capitan 10.11.1后,我无法在Android Studio中创建新的虚拟设备
从现在开始,当我创建一个新的虚拟设备并运行我的应用程序时,我有以下消息:
> emulator: The memory needed by this AVD exceeds the max specified in
> your HAXM configuration. HAXM is not working and emulator runs in
> emulation mode emulator: AVD RAM size = 1024 MB emulator: HAXM
> max RAM size = 512 MB emulator: You might want to adjust your AVD RAM
> size and/or HAXM configuration to run in fast virt mode. emulator:
> emulator window was out of view and …Run Code Online (Sandbox Code Playgroud) 在我的角度项目中,用户接受EULA,然后自动重定向到他们的仪表板,但是,在此重定向上,DashboardController似乎被调用了两次,DashboardController正在路由本身被调用,我已经检查过我是否有意外在模板中再次调用它,但我没有.以下是我的路线和控制器.如果我直接或通过EULA控制器上的重定向访问URL似乎没有关系,我得到相同的结果.
路线
.config(function($httpProvider, $stateProvider, $urlRouterProvider) {
$httpProvider.interceptors.push('httpRequestInterceptor');
$urlRouterProvider.otherwise('/');
$stateProvider
.state('login', {
url: '/',
templateUrl: 'templates/login.html',
data: {
requireLogin: false
}
})
.state('eula', {
url: '/eula',
templateUrl: 'templates/eula.html',
data: {
requireLogin: true
}
})
.state('dashboard', {
url: '/groups',
templateUrl: 'templates/dashboard.html',
data: {
requireLogin: true
}
})
});
Run Code Online (Sandbox Code Playgroud)
控制器:
App.controller('DashboardController', ['$scope', 'RequestService', '$state', '$rootScope', function($scope, RequestService, $state, $rootScope){
alert('test');
}]);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
根据评论添加我的HTML
的index.html
<body ng-app="App">
<ion-nav-bar class="bar-positive nav-title-slide-ios7" align-title="center">
<ion-nav-back-button class="button-icon ion-arrow-left-c"></ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view class="slide-left-right"></ion-nav-view>
<ui-view></ui-view>
</body>
Run Code Online (Sandbox Code Playgroud)
dashboard.html
<div class="groups" ng-controller="DashboardController">
<ion-view …Run Code Online (Sandbox Code Playgroud) javascript angularjs angularjs-routing angularjs-controller ionic-framework
我正在创建一个包含带有嵌套CardView的RecyclerView的Android应用程序.我需要将每张其他卡换成不同的颜色.我@Override用来覆盖这个onBindViewHolder(ViewHolder vh, int pos)方法.我需要更改该方法的背景颜色(我假设),但没有方法来设置ViewHolder的背景颜色!
对不起我的诺言,我正在学习Android开发.
-ben
编辑:代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_9);
pieRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
pieRecyclerView.setHasFixedSize(true);
pies = makePies();
pieLayoutManager = new LinearLayoutManager(this);
pieRecyclerView.setLayoutManager(pieLayoutManager);
PieAdapter adapter = new PieAdapter(pies);
pieRecyclerView.setAdapter(adapter);
}
public class PieAdapter extends RecyclerView.Adapter<ViewHolder> {
Context mContext;
ArrayList<Pie> mPies;
LayoutInflater mInflater;
public PieAdapter(ArrayList<Pie> pies) {
mPies = pies;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_layout, parent, false);
return new ViewHolder(v);
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) android ×2
angularjs ×1
cookies ×1
haxm ×1
javascript ×1
json ×1
nsurlsession ×1
setcookie ×1
swift ×1