我只是想更好地理解我经常用来优化的以下模式 ListView
我的读物只指出了一个事实,即静态内部类被视为顶级类.与成员类(非静态)相比,这样的东西有什么好处?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Comment comment = getItem(position);
ViewHolder holder;
if (convertView == null){
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.mylayout, null);
holder.nickname = (TextView) ((ViewGroup) convertView).findViewById(R.id.nickname);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
holder.nickname.setText(comment.getMember_nickname());
CharSequence
return convertView;
}
public static class ViewHolder{
TextView nickname;
}
Run Code Online (Sandbox Code Playgroud) 我需要在几毫秒内从系统中获取当前时间.我正在使用XCode 5.1.1,我试过以下,
long timePassed_ms = ([[NSDate date] timeIntervalSince1970] * 1000);
这与iPad Retina(64-bit)模拟器工作正常.但是当我在iPad(32 bit)模拟器上运行它时,它返回负值.
产量
In 32bit iPad : -2147483648
In 64bit iPad : 1408416635774(This is the correct time)
有人能帮忙吗?
提前致谢!
我有一个li像下面这样的 ul。
<li class="list-group-item" data_id="1909" id="1909"><input type="checkbox" class="checkboxes" value="1909" name="Navigate Window">Navigate Window</li>
Run Code Online (Sandbox Code Playgroud)
我尝试li使用以下代码更改此文本。
$('#list1 #' + selectedId).text('abcd');
Run Code Online (Sandbox Code Playgroud)
使用此代码,文本更改得很好。但它丢失input了li. 如何防止整个替换li?
而且我在stackoverflow中尝试了以下内容。 只更改 li 中包含 img 的文本
我试过如下,
$("ul.list-group > li.list-group-item > span.thetext").html('abcd');
Run Code Online (Sandbox Code Playgroud)
我的ul班级是list-group。但我失败了。怎么能做到这一点?
提前致谢!
我有一个订阅主题的 kafka 消费者。实施工作正常。但是当尝试为此实现单元测试时,由于它是通过Runnable接口实现的,所以存在问题。
执行
@Override
public void run() {
kafkaConsumer.subscribe(kafkaTopics);
while (true) {
ConsumerRecords<String, String> records = kafkaConsumer.poll(1000);
Map<String, InventoryStock> skuMap = new LinkedHashMap<>();
try {
// populating sku map with consumer record
for (ConsumerRecord<String, String> record : records) {
populateMap(skuMap, record.value());
}
if (MapUtils.isNotEmpty(skuMap)) {
// writing sku inventory with populated sku map
inventoryDao.updateInventoryTable(INVENTORY_JOB_ID, skuMap);
}
} catch (Exception e) {
}
kafkaConsumer.commitAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用MockConsumer. 但是需要在实现中分配给消费者。但是消费者在实现中并没有暴露在外。这是我尝试过的。
@Before
public void onBefore() {
MockitoAnnotations.initMocks(this);
Properties consumerProps …Run Code Online (Sandbox Code Playgroud) 我有3GB大小的数据文件要上传到GCP云存储中。我尝试了“ GCP上传对象”教程中的示例。但是,当我尝试上传时,出现以下错误。
java.lang.OutOfMemoryError: Required array size too large
Run Code Online (Sandbox Code Playgroud)
我尝试如下
BlobId blobId = BlobId.of(gcpBucketName, "ft/"+file.getName());
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
Blob blob = storage.get().create(blobInfo, Files.readAllBytes(Paths.get(file.getAbsolutePath())));
return blob.exists();
Run Code Online (Sandbox Code Playgroud)
我该如何解决?是否可以使用GCP Cloud Storage Java客户端上传大文件?
我有一个单元测试来测试将文件上传到 GCP 存储。这是上传文件的代码。
@Override
public boolean upload(StorageConfiguration storageConfiguration, File file) throws MetaFeedException {
// get google storage connection.
Optional<Storage> storage = getStorageConnection(storageConfiguration.getJsonCredentialFilePath());
// if GCP storage is empty, return empty.
if (!storage.isPresent()) {
throw new MetaFeedException("Failed to establish connection with GCP storage");
}
// upload blob with given file content
BlobId blobId = BlobId.of(storageConfiguration.getBucketName(),
storageConfiguration.getBucketPath().concat(file.getName()));
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType(storageConfiguration.getContentType()).build();
try {
return storage.get().create(blobInfo, Files.readAllBytes(Paths.get(file.getAbsolutePath()))).exists();
} catch (Exception e) {
throw new MetaFeedException("Error occurred while uploading file.", e);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的单元测试中,我做了这样的事情, …
java junit mockito google-cloud-storage google-cloud-platform
我的jsp文件中有以下行:
var option = document.createElement('<option value="NO">');
Run Code Online (Sandbox Code Playgroud)
不知道为什么这给了我InvalidCharacterError.
任何替代品?
Scala.Array包含一个函数toArray,作为ArrayOps的隐式导入.
是否有Array.toArray的用例或它是否总是返回该对象的副本?
我有一个.zip文件夹,其中包含一些图像.我希望它解压缩到iOS设备中的Documents目录.我尝试了以下链接,
在iOS-Stack Overflow下载和解压缩文件 这是我在我的应用程序中尝试的代码,
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filepath = [documentsDirectory stringByAppendingPathComponent:@"Obj.zip"];
ZipArchive *zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:filepath Password:@""];
[zipArchive UnzipFileTo:[documentsDirectory stringByAppendingPathComponent:@"Obj"] overWrite:YES];
[zipArchive UnzipCloseFile];
Run Code Online (Sandbox Code Playgroud)
然后我打印了所有文件Document Directory,但是文件目录中Obj.zip存在的唯一文件(Obj.zip是要解压缩的文件).我怎么能这样做?
提前致谢!
java ×4
ios ×3
objective-c ×3
javascript ×2
android ×1
apache-kafka ×1
arrays ×1
date ×1
html ×1
html-lists ×1
ipad ×1
jquery ×1
jsp ×1
junit ×1
mockito ×1
scala ×1
xcode5 ×1
ziparchive ×1