我正在尝试创建一个自定义cursoradapter,它将根据游标中的某些数据使用两种不同的布局.我一直在阅读'覆盖getViewTypeCount()和getItemViewType()'来实现这一点,但我似乎无法弄清楚如何实现这一点.
这是我的bindView和新的View方法的代码:
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView tView = (TextView) view.findViewById(R.id.TextView1);
tView.setText("The text");
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return mInflater.inflate(R.layout.item1, parent, false);
}
Run Code Online (Sandbox Code Playgroud)
.
编辑: 现在我有这个工作,但我想选择使用什么rowlayout取决于光标中的一些数据,我不能得到那个工作..任何人有一些想法?
@Override
public int getItemViewType(int position) {
return position % 2;
}
@Override
public int getViewTypeCount() {
return 2;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder holder = (ViewHolder) view.getTag();
holder.txtAddress
.setText("blabla");
}
@Override
public View newView(Context context, …Run Code Online (Sandbox Code Playgroud) 我如何使用ActiveForm满足这些要求?
使用ajax提交表单.
在使用ajax提交之前:检查是否有错误退出.
提交后:如果服务器响应不成功保存结果,则在字段输入下显示字段错误.
在我的Yii2应用程序中,我试图强制所有用户进行身份验证.如果它们尚未经过身份验证,则应将其重定向到登录页面.
在Yii1中,我通过创建一个类来检查用户是否已登录并将该类附加到onBeginRequest我的主配置文件中的行为来完成此操作.
// Yii 1
'behaviors' => array(
'onBeginRequest' => array(
'class' => 'application.components.RequireLogin',
)
),
Run Code Online (Sandbox Code Playgroud)
如何在Yii2中获得相同的行为?我知道我可以使用行为来执行此操作,但我不想将此行为添加到我的主配置文件中,因此首先检查所有请求的身份验证.
工作行为方法如下所示:
// Yii2
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 formik 创建登录表单。我对如何触发 handleSubmit 函数来调用登录 api 供用户登录感到困惑。我一直在 onSubmit 内调用handleSubmit,但它无法识别 ValidatedLoginForm.js 文件中的codesandbox 中第10 行和第11 行的onSubmit 方法内的值和handleSubmit。我到底在哪里调用handleSubmit并让用户登录我的网站?
我的代码看起来像这样:
import React, { useState } from "react";
import { Formik } from "formik";
import TextField from "@material-ui/core/TextField";
import * as Yup from "yup";
const ValidatedLoginForm = props => (
<Formik
initialValues={{ email: "", password: "" }}
onSubmit={values => {
const handleSubmit = async event => {
event.preventDefault();
var body = {
password: password,
email: email
};
console.log(body);
const options = {
method: "POST", …Run Code Online (Sandbox Code Playgroud) 我想提醒用户会话超时即将到期.我想要一个带有OK按钮的弹出窗口,并在弹出窗口中显示秒数.我可以用java脚本吗?我也可以使用C#代码.
现在它检测到会话超时并弹出告诉他们会话已过期.
<script type="text/javascript">
var sessionTimeout = "<%= Session.Timeout %>";
function DisplaySessionTimeout() {
sessionTimeout = sessionTimeout - 1;
if (sessionTimeout >= 0)
window.setTimeout("DisplaySessionTimeout()", 60000);
else {
alert("Your current Session is over due to inactivity.");
}
}
</script>
Run Code Online (Sandbox Code Playgroud) 在重复问题之前,请确保您阅读了我的问题
\n\n我在 2019 年问这个问题,React Js 文档指定我们可以在我们的 React 项目中使用 SASS链接
\n\n我想使用由用户单击控制的动态变量在浅色主题和深色主题之间切换
\n\n我的反应代码
\n\nimport React from \'react\';\nimport \'./App.scss\';\n\nclass App extends React.Component {\n render() {\n return (\n <div className="Home">\n I\xe2\x80\x99m slow and smooth\n <button onClick={() => console.log()}>Change theme</button>\n </div>\n ); \n }\n}\n\nexport default App;\nRun Code Online (Sandbox Code Playgroud)\n\n我的SASS代码:
\n\n$theme: light; // I want to control this variable\n\n$bgcolor: #222222;\n\n@if($theme== light) {\n $bgcolor: white; \n}\n@else {\n $bgcolor: black; \n}\n\n.Home {\n background-color: $bgcolor;\n height: 100vh;\n}\nRun Code Online (Sandbox Code Playgroud)\n 虽然我为 SearchDropDownItem 定义了一个键,但它显示了一个警告
组件下拉
filteredItems.length > 0 ? (
filteredItems.map(item => {
return (
<SearchDropDownItem
item={item}
buttonTitle={{ buttonJoin: content.buttonJoin }}
onItemSelect={onItemSelect}
/>
);
})
) : (
<SearchDropDownItem emptyList={content.noCommunityFound} />
)
Run Code Online (Sandbox Code Playgroud)
searchDropDownItem 组件:
const SearchDropDownItem = ({
item = { },
onItemSelect,
buttonTitle = "",
emptyList
}) => {
return (
<DropdownItem key={item.id || 1}>
{!emptyList ? (
<Box>
<Span>{item.name} </Span>
<JoinButton
item={item}
index={item.id}
onSuccess={onItemSelect}
content={buttonTitle}
/>
</Box>
) : (
<Box>
<Span>{item.emptyList}</Span>
</Box>
)}
</DropdownItem>
);
};
Run Code Online (Sandbox Code Playgroud)
警告: …
当我取出条件来加载数据时它将它保存到db,$ _POST获取值但不会将它们发送到控制器,这种方式适用于我的其他项目但不在此处.如果我if(isset($_POST['money']) && isset($_POST['username'])){用来保存数据,它可以工作但不是load()功能.
调节器
public function actionSend() {
$model = new User();
$model->getErrors();
if ($model->load(Yii::$app->request->post())) {
$model->money = 'something';
$model->username = 'something';
$model->save();
}
return $this->render('send', [
'model' => $model
]);
}
Run Code Online (Sandbox Code Playgroud)
模型
<?php
namespace app\models;
use yii\db\ActiveRecord;
use Yii;
class User extends \yii\db\ActiveRecord {
public static function tableName() {
return 'user';
}
public function rules() {
return [
[['username', 'money'], 'safe'],
[['username', 'password'], 'string', 'max' => 15],
[['auth_key', 'access_token'], 'string', 'max' => 32],
[['money'], …Run Code Online (Sandbox Code Playgroud) 我有:
Pattern pat = Pattern.compile("(\\d+) (\\d+) (1$)");
Matcher mat = pat.matcher(line);
Run Code Online (Sandbox Code Playgroud)
与匹配:
1 2 1
Run Code Online (Sandbox Code Playgroud)
但不适用于:
1 2 1
Run Code Online (Sandbox Code Playgroud)
我怎样才能实现,根据数字之间的空格,模式匹配是不切实际的?
reactjs ×4
javascript ×2
php ×2
yii ×2
yii2 ×2
active-form ×1
ajax ×1
android ×1
arrays ×1
asp.net ×1
c# ×1
database ×1
ecmascript-6 ×1
formik ×1
forms ×1
java ×1
listview ×1
material-ui ×1
rbac ×1
react-native ×1
regex ×1
sass ×1