我正在使用jQuery-UI 在我的页面上添加选项卡,在我添加它之后,我觉得选项卡字体大小和选项卡宽度和高度对于我的页面来说太大了.我想更改字体大小和标签宽度和高度.怎么做?
我有一个ListView
(my_list.xml):
<ListView
android:id="@+id/my_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
/>
Run Code Online (Sandbox Code Playgroud)
每个列表项的布局是(list_item.xml):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
>
<ImageView
android:id = "@+id/my_icon"
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:layout_centerVertical="true"
/>
<TextView
android:id="@+id/my_str"
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:layout_toRightOf="@id/my_icon"
/>
<!--This radio button makes the list item unselectable, why?-->
<RadioButton
android:id="@+id/my_radio_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在Java代码中,我SimpleAdapter
用于列表:
my_list = (ListView) findViewById(R.id.my_list);
SimpleAdapter adapter = new SimpleAdapter(context, getOptions(),
R.layout.list_item,
new String[] { "icon1","str1" },
new int[] …
Run Code Online (Sandbox Code Playgroud) android android-widget android-emulator android-intent android-layout
从Android 6.0开始,在运行时请求权限,而不是在安装之前.
Android 官方doc推荐以下代码:
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
...
}
}
Run Code Online (Sandbox Code Playgroud)
我对以上示例代码中的一件事感到困惑,这就是为什么上面的评论说" 向用户异步显示解释 "?这是一个遵循的惯例吗?我的意思是,如果我只是打算弹出一个对话框来解释为什么需要权限,我不认为需要异步弹出对话框.我只是不明白为什么谷歌推荐异步代码. …
我看了一个字典数据,其值如下:
var myDict = ["name": "John",
"age": 28]
Run Code Online (Sandbox Code Playgroud)
我看到如下代码:
myDict.flatMap {
let a = $0.0
let b = $0.1
...
}
Run Code Online (Sandbox Code Playgroud)
什么$0.0
意思?什么$0.1
意思?$0
和之间有什么区别$0.1
?
我想在我的应用程序运行期间使用命令行ADB工具来崩溃我的Android应用程序,是否可以这样做?如何 ?
(基本上,我想测试我的应用程序是否在崩溃时保留必要的信息.所以,我想通过某些命令行工具(如ADB)使我的应用程序崩溃来演示这个.)
*****更新********
换句话说,如何使用ADB工具终止我的应用程序进程?
我有一个简单的类Foo
要被嘲笑:
public class Foo {
private String name;
public Foo() {
}
public Foo(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
Run Code Online (Sandbox Code Playgroud)
在我的单元测试代码中,我使用Mockito来模拟它.
Foo mockedFoo = Mockito.mock(Foo.class);
mockedFoo.setName("test");
// name is null
String name = mockedFoo.getName();
Run Code Online (Sandbox Code Playgroud)
我设置name
了模拟对象,但是当我调用getter获取名称时,它返回null.
它是一个Mockito特定的问题还是一个惯例,模拟对象不能设置值?这是为什么?下面用模拟对象发生了什么?
我正在使用AlamofireObjectMapper来解析对我的对象的json响应.AlamofireObjectMapper是ObjectMapper的扩展.
根据他们的文件,我的模型类必须符合Mappable
协议.例如:
class Forecast: Mappable {
var day: String?
var temperature: Int?
var conditions: String?
required init?(_ map: Map){
}
func mapping(map: Map) {
day <- map["day"]
temperature <- map["temperature"]
conditions <- map["conditions"]
}
}
Run Code Online (Sandbox Code Playgroud)
为了符合Mappable protocl,我的模型类必须为每个字段实现所需的初始化器和映射函数.这说得通.
但是,它如何支持struct
类型?例如,我有一个Coordinate
结构,我尝试符合Mappable
协议:
struct Coordinate: Mappable {
var xPos: Int
var yPos: Int
// ERROR: 'required' initializer in non-class type
required init?(_ map: Map) {}
func mapping(map: Map) {
xPos <- map["xPos"] …
Run Code Online (Sandbox Code Playgroud) 我正在使用OCMock 3来测试我的iOS项目.
我使用dispatch_once()
创建了一个单例类MyManager
:
@implementation MyManager
+ (id)sharedInstance {
static MyManager *sharedMyManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedMyManager = [[self alloc] init];
});
return sharedMyManager;
}
Run Code Online (Sandbox Code Playgroud)
我在School
课堂上有一个使用上述单例的方法:
@implementation School
...
- (void) createLecture {
MyManager *mgr = [MyManager sharedInstance];
[mgr checkLectures];
...
}
@end
Run Code Online (Sandbox Code Playgroud)
现在,我想对这个方法进行单元测试,我使用MyManager的局部模拟:
- (void) testCreateLecture {
// create a partially mocked instance of MyManager
id partialMockMgr = [OCMockObject partialMockForObject:[MyManager sharedInstance]];
// run method to test
[schoolToTest createLecture];
... …
Run Code Online (Sandbox Code Playgroud) 我正在开发Rails 3.1应用程序,我很困惑我应该在哪里放置我自己的javascript代码(例如my.js)以及在哪里放置第三方javascript库(例如jQuery-UI).
我知道在旧版本的Rails中,javascript应该全部进入public/javascripts /目录,当我生成Rails 3.1应用程序时,没有public/javascripts /文件夹,但是有app/assets /和verndor/assets /并且有在app/assets中的application.js,我想问一下:
- - - - - - - - 我对吗? - - - - -
是require_tree
在application.js中被用于包括根据第三方库的应用程序/供应商/资产/ JavaScript的/
和require "something"
在的application.js用于包括下JS文件的应用程序/资产/ Javascript角/ ?? 我对吗?
我有一个NSTimeInterval
值,我需要dispatch_time_t
用它创建一个值.这是我试过的:
let timeInterval : NSTimeInterval = getTimeInterval()
//ERROR: Binary operator '*' cannot be applied to operands of type 'NSTimeInterval' and 'UInt64'
let dispatch_time = dispatch_time(DISPATCH_TIME_NOW, Int64(timerInterval * NSEC_PER_SEC))
Run Code Online (Sandbox Code Playgroud)
我理解这个错误信息,但我不知道如何摆脱它.有人可以提供一些建议吗?如何创建dispatch_time
实例NSTimeInterval
?谢谢!