按钮并排LinearLayout(Button side by side LinearLayout)
大家好,我正在尝试将按钮并排,但我似乎无法让它工作。 我真的试过搞乱并尝试谷歌但失败了。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:orientation="vertical" android:weightSum="1"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Name" android:id="@+id/name" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/nameText" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:layout_gravity="right" />
我怎么会这样做?
Hello guys I am trying to make the buttons side by side but I cant seem to get it work. I really tried messing around and tried google but failed.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:orientation="vertical" android:weightSum="1"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Name" android:id="@+id/name" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/nameText" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:layout_gravity="right" />
How would I do it guys?
原文:
2022-08-01 09:08
满意答案
你需要序列化你的params字典,然后对它进行字符串编码,因为你的body参数中有一个JSON对象。 试试这个:
NSDictionary *params = @{@"email": @"email@gmail.com", @"name": @"myName"}; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil]; NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSDictionary *dict = @{@"body":json}; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager POST:@"http://myURL.com/user" parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSString *myString = [[NSString alloc] initWithData:operation.request.HTTPBody encoding:NSUTF8StringEncoding]; NSLog(@"Error: %@", myString); }];
You need to serialize your params dictionary and then string encode it, since your body parameter has a JSON object in it. Try using this :
NSDictionary *params = @{@"email": @"email@gmail.com", @"name": @"myName"}; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil]; NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSDictionary *dict = @{@"body":json}; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager POST:@"http://myURL.com/user" parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSString *myString = [[NSString alloc] initWithData:operation.request.HTTPBody encoding:NSUTF8StringEncoding]; NSLog(@"Error: %@", myString); }];
相关问答
更多如何从AFNETWORKING POST获取参数(How to GET parameters from AFNETWORKING POST)
你面临的问题是你看错了地方。 正如你所说的,你正在使用AFNetworking的POST方法来发布数据。 强调POST。 GET和POST是两个完全不同的东西。 GET用于检索存储在url中的值,例如www.example.com/example-get.php?key1=value1&key2=value2 。 您可以通过执行$_GET['key1']访问PHP中的不同值。 POST是不同的。 这与HTTP消息正文一起发送,并且不能在浏览历史记录或url中看到。 你可以通过使用$_POST['f...
AFNetworking 2.0多部分/表格数据上传到mySQL(AFNetworking 2.0 multipart/form-data upload to mySQL)
我已经弄清楚了。 这是从文本字段和UIImageVIew发布图像和文本: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json",nil];
manager.responseSer...
使用Objective-C打印多部分/表单数据(POST multipart/form-data with Objective-C/Swift)
过程如下: 使用userName , userEmail和userPassword参数创建字典。 NSDictionary *params = @{@"userName" : @"rob",
@"userEmail" : @"rob@email.com",
@"userPassword" : @"password"};
确定图像的路径: NSString *path = [[NSBu...
iOS - 如何将数组作为参数传递给AFNetworking(Objective-C)(iOS - How to pass array to AFNetworking as parameters (Objective-C))
你必须将路径数组作为参数@ {@“data”:@ [params]} NSDictionary *foo = @{
@"id" : @"2011011",
@"request" : @"single",
@"gender" : @"M",
@"username" : @"name",
...
AFNetworking POST并获取数据(AFNetworking POST and get Data back)
您正在使用一种复杂的方法来构建操作,但它会起作用。 但它应该工作,你缺少的是分配XMLparser。 在AFXMLRequestOperation的文档中说明。 NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"http://myPath/Iphone/method" parameters:params];
AFXMLRequestOperation *operation = [[AFXMLR...
AFNetworking中的ASIFormDataRequest?(ASIFormDataRequest in AFNetworking?)
您遇到的问题是因为您正在实例化AFJSONRequestOperation,默认情况下需要一个JSON友好的响应类型。 您是否期待JSON响应? 如果没有,您应该使用一个不太具体的Request类。 例如,您可以使用HTTPRequestOperationWithRequest :. NSURL *url = [NSURL URLWithString:@"http://dev.url"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initW...
AFNetworking 3.0用于上传图像错误的多部分表单数据(AFNetworking 3.0 Multipart form data for uploading image error)
使用此方法 -(void)callWebserviceToUploadImageWithParams:(NSMutableDictionary *)_params imgParams:(NSMutableDictionary *)_imgParams videoParms:(NSMutableDictionary *)_videoParams action:(NSString *)_action success:(void (^)(id))_success failure:(void (^)(NS...
清空$ _POST和$ _FILES,但非空的php://输入multipart / form-data请求,iOS AFNetworking库(Empty $_POST and $_FILES, but non empty php://input on multipart/form-data request, iOS AFNetworking library)
在NSMutableURLRequest的帮助下,我们通过使用我们自己的多部分POST请求实现解决了iOS上的问题。 仍然没有回答为什么我们不能使用AFNetworking或在Postman,Android和AngularJS上放置Content-Type标头。 我们有一种强烈的感觉,AFNetworking的问题是发送请求分块(header transfer-encoding: chunked )。 我们实际上在我们的自定义iOS实现上发送了Content-Type: multipart/for...
Objective-C如何使用AFNetworking发布表单数据?(Objective-C How to POST form-data using AFNetworking?)
你需要序列化你的params字典,然后对它进行字符串编码,因为你的body参数中有一个JSON对象。 试试这个: NSDictionary *params = @{@"email": @"email@gmail.com", @"name": @"myName"};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil];
NSString *json = [...
Objective-C AFnetworking:停止请求(Objective-C AFnetworking: stopping a request)
这篇文章可能有帮助。 尝试: [manager.operationQueue cancelAllOperations];
This post may help. Try: [manager.operationQueue cancelAllOperations];
相关文章
更多Riak, haproxy, and client side applications
转载:http://blog.dloh.org/Riak,-haproxy,-and-client-s
...
[Android]用LinearLayout 实现类微信消息列表项
实现效果: 微信参照界面: 一个关键点: "早晚报"与"下午
...
Flex 如何输出日志
我们在编写Flex应用程序的时候经常会忽略logging,发现问题需要debug的时候用的最多的就是A
...
Hadoop实现数据库表关联
Hadoop实现数据库表关联主要有两种方式:Map Side Join和Reduce Side Joi
...
mmseg4j相关
http://mmseg4j.googlecode.com/files/mmseg4j-1.8.4.z
...
游戏相关网站
http://www.gamepyong.com/ http://www.freewebs.com/p
...
按钮样式
网页上有很多功能是通过链接方式传递参数,这种功能链接普通样式就是一个超链接退出,如果将超链接的样式变成
...
jqgrid删除按钮出问题
jqgrid删除按钮出问题 我写的代码如下: function getGrid(){ // 定义
...
用‘button’跟‘text’组合代替‘file’,选择文件后点‘submit’,‘file’的值被清空
各位大虾晚上好,我有个问题想请教你们,我想美化html的file外观,但貌似现在还不能用css直接设计
...
Android按钮根据文本框设置状态
现在有一个需求其实挺简单的,就是按钮根据文本框里的信息设置禁用或者可用的状态,即如果文本框(TextV
...
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {
如何通过引用返回对象?(How is returning an object by reference possible?)
这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m
矩阵如何存储在内存中?(How are matrices stored in memory?)
正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man
每个请求的Java新会话?(Java New Session For Each Request?)
你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl
xcode语法颜色编码解释?(xcode syntax color coding explained?)
转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!