我正在尝试填充列表视图,其中行包含复选框,四个textviews和两个微调器.每行上的微调器中的值需要不同,因为它们与该行上的实际项直接相关.只是为了使它变得更复杂一点,除非选中复选框,否则微调器和它们旁边的两个文本字段是不可见的(setVisibility(View.GONE)).我只想要列表项可点击(而不是复选框),并且一旦显示,微调器就需要可点击.
我的所有代码都正常工作,除了当填充微调器时,我失去了单击该行上的列表项的能力.我仍然可以从该行上的微调器中选择值,但触摸该行上的任何其他位置都没有任何作用.有些行不会将数据返回到微调器,并且它们继续正常运行,因此我认为它与连接到微调器的适配器有关.
此外,我知道我将不得不考虑列表视图回收,但我还没有那么远.
我希望有人能在我完全疯了之前指出这里有什么问题.
这是listview xml
<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/empty"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是行xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<CheckBox android:id="@+id/pl_selected"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"
android:layout_weight="1"/>
<TextView android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"/>
<TextView android:id="@+id/name2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/pl_tv1"
android:text="@string/pl_tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false"
android:visibility="gone"/>
<Spinner android:id="@+id/pl_spin1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone"
android:focusableInTouchMode="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/pl_tv2" …Run Code Online (Sandbox Code Playgroud) 好的,我一定在这里遗漏了一些非常简单的东西。我只想从 user_id 匹配的表中返回所有记录(简单!)并且“已支付”字段为 NULL 或 0。我的“已支付”字段是 TinyInt (1)。
我的 CakePHP 模型代码是:
$workingRecord = $this->find('first',array(
'conditions'=>array(
'Subscription.user_id'=>$userId,
array('not' => array('Subscription.paid' => true)) // Not True, to catch both false or NULL values
)
));
Run Code Online (Sandbox Code Playgroud)
CakePHP 生成的 SQL 是这样的:
SELECT `Subscription`.`id`, `Subscription`.`paid` FROM `subscriptions` AS `Subscription` WHERE `Subscription`.`user_id` = 3 AND NOT (`Subscription`.`paid` = '1') LIMIT 1
Run Code Online (Sandbox Code Playgroud)
常识会说这应该有效。问题是 SQL 将返回 'paid' 列中包含 0 的行,但永远不会返回 NULL。
有没有办法在不使用“或”的情况下一次性返回零和空值?
提前致谢。
表
restaurants
cuisines
cuisines_restaurants
Run Code Online (Sandbox Code Playgroud)
餐厅和美食模型都是HABTM彼此设置的.
我正在尝试获取一个餐馆的分页列表,其中Cuisine.name ='italian'(示例),但不断收到此错误:
1054: Unknown column 'Cuisine.name' in 'where clause'
Run Code Online (Sandbox Code Playgroud)
它正在构建的实际查询:
SELECT `Restaurant`.`id`, `Restaurant`.`type` .....
`Restaurant`.`modified`, `Restaurant`.`user_id`, `User`.`display_name`,
`User`.`username`, `User`.`id`, `City`.`id`,`City`.`lat` .....
FROM `restaurants` AS `Restaurant` LEFT JOIN `users` AS `User` ON
(`Restaurant`.`user_id` = `User`.`id`) LEFT JOIN `cities` AS `City` ON
(`Restaurant`.`city_id` = `City`.`id`) WHERE `Cuisine`.`name` = 'italian'
LIMIT 10
Run Code Online (Sandbox Code Playgroud)
"....."部分只是我删除的其他字段,以缩短查询以向您显示.
我不是CakePHP专家,所以希望有一些明显的错误.我正在调用这样的分页:
$this->paginate = array(
'conditions' => $opts,
'limit' => 10,
);
$data = $this->paginate('Restaurant');
$this->set('data', $data);
Run Code Online (Sandbox Code Playgroud)
$ opts是一系列选项,其中一个是'Cuisine.name'=>'italian'
我也试过设置$ this-> Restaurant-> recursive = 2; 但这似乎没有做任何事情(我认为我不应该这样做?) …
我正在尝试将textarea的内容复制到4到138个字符之间.
我的正则表达式如下: '/^.{4,138}$/'
但是 - 我希望用户能够包含返回字符,我相信"." 阻止他们这样做.关于我需要改变什么的想法?
编辑:
显然还有其他方法来获取文本的长度 - strlen...等,但我正在寻找正则表达式,因为检查的性质(即需要正则表达式的插件)
我读过的所有东西(在已经制作我的app :()后面写着"你永远不应该在ScrollView中使用WebView!".这是可以理解的,因为理论上你可以有两个滚动的东西,这将使奇怪的可用性.
但是 - 到目前为止,我没有看到任何不利影响.然后,我正在使用的每个WebView都不需要滚动 - 也许这使得它可以接受 - 即使它在技术上是错误的吗?
是否有不良影响,我只是没有注意到对特定版本的测试缺乏?
如果我不能在ScrollView中使用WebView,我将如何获得以下布局(我当前的应用程序):
LinearLayout
ScrollView
LinearLayout
TextView //Title of article
TextView //Subtitle of article
RelativeLayout
ImageView //Large Image (clickable to gallery)
ImageView //"more photos icon"
WebView // a small horizontal ad
TextView // actual article text
WebView //embedded HTML code ranging from iframe to video...etc
WebView //embedded HTML code ranging from iframe to video...etc
WebView // a small horizontal ad
LinearLayout
TextView //DB-driven "similar articles" list
WebView //disqus comments
Run Code Online (Sandbox Code Playgroud)
注意:我意识到这是"错误的" - 但 …
在CakePHP 3.0命名参数已被删除(感谢上帝),支持与其他应用程序框架内联的标准查询字符串参数.
我仍然在努力解决的问题是,在其他MVC框架中,例如ASP.NET,你将传递ActionResult中的参数(与函数相同):
Edit( int id = null ) {
// do stuff with id
}
Run Code Online (Sandbox Code Playgroud)
并且该方法将作为查询字符串传递给id:/Edit?id=1并且您将使用路由使其非常类似于:/Edit/1.
在CakePHP中,但是在函数参数中传递的内容如下:
function edit( $id = null ) {
// do stuff with $id
}
Run Code Online (Sandbox Code Playgroud)
必须作为传递参数完成,例如:/Edit/1绕过查询字符串的想法,以及路由以改进URL的需要.
如果我在该编辑的链接中命名params,如:
$this->Html->link('Edit', array('action' => 'edit', 'id' => $post->id));
Run Code Online (Sandbox Code Playgroud)
然后我必须这样做:
public function edit() {
$id = $this->request->query('id');
// do stuff with $id
}
Run Code Online (Sandbox Code Playgroud)
获取传递的参数id.想到它会在像CakePHP 3.0的ASP.NET中那样在功能中提取它,但事实并非如此.
我更喜欢在编辑链接中为传递的值添加前缀而不是仅仅传递它们,所以我不必在另一端担心序数,我知道它们是什么等等.
有没有人使用这些方法将数据传递给CakePHP中的方法,并且可以更好地了解正确的处理方式以及3.0版本中的更改将如何改善这一领域的内容......
我有一个div网格(使用Bootstrap3)(见下图).我希望它们像网格一样,但如果它们不是水平排列的,它们通常不像网格一样排列.
我认为这将是一个简单的解决方案,我仍然认为它可能是,但对于我的生活,我无法按照我希望的方式工作.
我已经尝试了很多组合添加左拉和拉右...等,但再次 - 没有任何工作.

我的意思的快速示例 - 具有动态变化高度的div网格:
<div class="col-lg-6 col-md-12">
Lorem ipsum<br>
Lorem ipsum<br>
Lorem ipsum<br>
</div>
<div class="col-lg-6 col-md-12">
Lorem ipsum<br>
Lorem ipsum<br>
</div>
<div class="col-lg-6 col-md-12">
Lorem ipsum<br>
Lorem ipsum<br>
Lorem ipsum<br>
Lorem ipsum<br>
</div>
<div class="col-lg-6 col-md-12">
Lorem ipsum<br>
Lorem ipsum<br>
Lorem ipsum<br>
</div>
<div class="col-lg-6 col-md-12">
Lorem ipsum<br>
Lorem ipsum<br>
</div>
Run Code Online (Sandbox Code Playgroud) 更新:
根据下面接受的答案的建议,我测试读取负数:
$negativeInt = -1;
Cache::write('my-test-count', $negativeInt, 'short');
$readVal = Cache::read('my-test-count', 'short');
debug($readVal);
exit;
Run Code Online (Sandbox Code Playgroud)
尝试读取任何负数时,反序列化错误会一致地重现。它现在是一个公认的错误,我认为它将在 2.8.1 之前解决
原问题:
我不断收到此错误,但无法弄清楚原因或什至如何进一步排除故障。
抛出错误的行只有在Cache::read()返回 false 时才会被命中。但是,如果我没有将 @ 放在它前面,那行本身就会抛出一个反序列化错误。
问题:
如何可靠地使用 Redis 进行计数而不会定期收到反序列化通知?如果密钥中的数据是“坏的”,我怎么知道不通过执行::read. 我试过确保我的数据是 (int)(见下文),但这似乎没有帮助。
注意 (8): unserialize(): Error at offset 0 of 2 bytes [APP/Vendor/pear-pear.cakephp.org/CakePHP/Cake/Cache/Engine/RedisEngine.php, line 136]
检查错误后:
> unserialize - [internal], line ??
> RedisEngine::read() - APP/Vendor/pear-pear.cakephp.org/CakePHP/Cake/Cache/Engine/RedisEngine.php, line 136
> Cache::read() - APP/Vendor/pear-pear.cakephp.org/CakePHP/Cake/Cache/Cache.php, line 358
> Cache::remember() - APP/Vendor/pear-pear.cakephp.org/CakePHP/Cake/Cache/Cache.php, line 567
> Item::getCount() - APP/Model/Item.php, line 812
Run Code Online (Sandbox Code Playgroud)
它似乎来自这个函数:
public …Run Code Online (Sandbox Code Playgroud) 我正在开发我的第一个 Flutter 应用程序(在我的 Android 手机上调试)。我有一个包含行项目的列表。当您长按该行时,它会将内容复制到用户的剪贴板中。这很好用!
但我需要让用户知道内容已被复制。
我试图按照许多教程来尝试让行被构建方法包围或在 Scaffold 内,但我无法工作。是否有另一种方法来通知用户(简单地)诸如“已复制!”之类的内容。发生?
注意Scaffold.of(...下面注释掉的。似乎必须有一种更简单的方法来通知用户,而不是将所有内容都包装在 Scaffold 中。(当我尝试时,它打破了我的布局)。
import 'package:flutter/material.dart';
import 'package:my_app/Theme.dart' as MyTheme;
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/services.dart';
class RowRule extends StatelessWidget {
final DocumentSnapshot ruleGroup;
RowRule(this.ruleGroup);
_buildChildren() {
var builder = <Widget>[];
if (!ruleGroup['label'].isEmpty) {
builder.add(new Text(ruleGroup['label'],
style: MyTheme.TextStyles.articleContentLabelTextStyle));
}
if (!ruleGroup['details'].isEmpty) {
builder.add(new Text(ruleGroup['details'],
style: MyTheme.TextStyles.articleContentTextStyle));
}
return builder;
}
@override
Widget build(BuildContext context) {
return new GestureDetector(
onLongPress: () {
Clipboard.setData(new ClipboardData(text: ruleGroup['label'] + " " + ruleGroup['details']));
// Scaffold.of(context).showSnackBar(SnackBar
// …Run Code Online (Sandbox Code Playgroud) 我可以看到 Flutter 允许我在字符串中使用 "\n\n" 并导致在Text项目中出现换行符:
final String answer = "This is my text.\n\n"
"Here is the 2nd line.";
Run Code Online (Sandbox Code Playgroud)
这是我的文字。
这是第 2 行。
但是,当我尝试使用从 firebase 中提取的内容并设置在变量中时,实际上会打印换行符(“\n”):
final String answer = faq['answer'];
Run Code Online (Sandbox Code Playgroud)
节目:
这是我的文字。\n\n这是第二行。
如何让我的“\n\n”实际显示为换行符?
cakephp ×4
php ×4
android ×2
flutter ×2
cakephp-1.3 ×1
cakephp-2.0 ×1
cakephp-2.1 ×1
cakephp-2.5 ×1
cakephp-3.0 ×1
css ×1
html ×1
line-breaks ×1
mysql ×1
redis ×1
regex ×1
snackbar ×1
spinner ×1