可能吗?甚至更好,是否可以使用jQuery?
我需要知道是否使用单击后退按钮或前进按钮,以便我可以正确使用页面过渡效果,例如.从左到右滑动,如果它们向前滑动,反之亦然.
我目前正在尝试实现一个 clickListener。我发现了一个很棒的运行时工具,它叫做 Overlap2D,在那里我制作了一些漂亮的按钮并加载它们,一切都工作正常。因为我想为我的按钮制作“悬停”效果,所以我使用了 ClickListener 和方法进入和退出,它看起来是这样的:
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor){
playButton.setLayerVisibility("MouseOver", true);
playButton.setLayerVisibility("pressed", false);
playButton.setLayerVisibility("normal", false);
System.out.println("Actor enter : "+fromActor);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor){
playButton.setLayerVisibility("MouseOver", false);
playButton.setLayerVisibility("pressed", false);
playButton.setLayerVisibility("normal", true);
System.out.println("Actor exit : "+toActor);
}
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button){
System.out.println("touchdown");
return true;
}
@Override
public void touchUp (InputEvent event, float x, float …Run Code Online (Sandbox Code Playgroud) 当我尝试onClick在我的 Google 中设置方法时SignInButton:
android:onClick="@{() -> viewModel.onGoogleLoginClick()}"
我总是收到这个错误:
发现数据绑定错误。
****/ 数据绑定错误 ****msg: 找不到正确的 android:onClick 回调类。尝试 android.view.View 但它有 0 个抽象方法,应该有 1 个抽象方法。
文件:/Users/user/Android/project/app/src/main/res/layout/activity_login.xml loc:53:31 - 53:66 ****\ 数据绑定错误****
这是我的代码:
活动登录.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.login.LoginActivity">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="com.example.myapp.ui.login.LoginViewModel" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/default_layout_padding">
<EditText
android:id="@+id/login_name_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/login_username_hint"
android:inputType="text"
android:text="@{viewModel.mEmail}" />
<EditText
android:id="@+id/login_pass_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_name_editText"
android:hint="@string/login_password_hint"
android:inputType="numberPassword"
android:text="@{viewModel.mPassword}" />
<Button
android:id="@+id/login_login_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/login_pass_editText"
android:onClick="@{() -> viewModel.onServerLoginClick()}"
android:text="@string/login_login_button_text" …Run Code Online (Sandbox Code Playgroud) 如何根据 TextFormField 的内容激活/停用按钮?
如果 TextFormField 有 10 个输入的数字(如果是手机号码),我想确保用户只能按按钮 X。
谢谢!
RaisedButton(
color: Colors.blueAccent,
onPressed: () =>sendData(); //fun1
signupPage(context) //fun2
child:
Text("Signup"),
)
Run Code Online (Sandbox Code Playgroud)
此代码给出错误..预计会找到')'
我试图让 SwiftUI 中的一个按钮在文本旁边显示一个图像。但是,图像显示为黑色,即使它在不在按钮中时显示。我需要对我的代码进行哪些编辑才能正确显示图像。
这是我目前的代码:
List{
Button(action: {
self.changeAppIcon("AlternateIcon5")
}) {
HStack {
Image("AlternateIcon5")
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(10.0)
Text("Navy Blue")
}
}
HStack {
Image("AlternateIcon5")
.resizable()
.frame(width: 50, height: 50)
.cornerRadius(10.0)
Text("Test")
}
}
Run Code Online (Sandbox Code Playgroud)
这是它显示的内容:
我想在按下按钮时更改图像名称。
到目前为止,这是我的结构:
struct ContentView: View {
@State var matrix = [Int] var
body: some View {
VStack {
Text("Test")
HStack(alignment: .center, spacing: 8) {
Button(action: {
**
// call a func that will do some check and
// change the image from Blue.png to Red.png
**
}) {
Image("Blue")
.renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fill)
.clipShape(Circle())
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 这是main.dart
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
return MaterialApp(
title: 'List',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.green,
),
home: HomeScreen());
}
}
Run Code Online (Sandbox Code Playgroud)
这是主屏幕.dart
class HomeScreen extends StatefulWidget {
HomeScreen({Key key}) : super(key: key);
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _currentindex = 0;
final List<Widget> screen = [
DashboardNavigator(),
RegisterPage(),
];
Future<bool> _onBackPressed() {
return showDialog(
context: context,
builder: (context) => new AlertDialog( …Run Code Online (Sandbox Code Playgroud) 这是我的第一篇文章,如果我忘记了什么,很抱歉......
对于我的工作,我必须使用 Material UI,并且我需要一个带有一些包含样式(如真正的按钮)的 IconButton!
我设法使用 Mui 组件的完整复制粘贴来完成此操作:https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/IconButton/IconButton.js
我所做的只是添加基于 Button 组件的包含样式的代码和样式,但我认为这不是正确的方法...我想导入 IconButton 作为别名并添加变体一些新样式的道具,但我不知道该怎么做。
这是我的组件:
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { chainPropTypes } from '@material-ui/utils';
import withStyles from '@material-ui/core/styles/withStyles';
import ButtonBase from '@material-ui/core/ButtonBase';
import { fade } from '@material-ui/core/styles/colorManipulator';
import capitalize from '@material-ui/core/utils/capitalize';
// TODO Better use of MUI possible ? -> Not copying the component but overriding it ?
// TODO Bug with Dark Mode
export const styles = …Run Code Online (Sandbox Code Playgroud) 我想单击 SwiftUI 中的一个按钮来触发 JSON 编码操作。此操作非常耗时,因此我需要它是异步的。我已经尝试了两种解决方案,但它们不起作用。一个主要问题是如何创建异步版本的 json 编码?
\n解决方案1)
\npublic func encodeJSON<T>(_ value: T, encoder: JSONEncoder, completionHandler: @escaping (Data?, Error?) -> Void) where T: Encodable {\n DispatchQueue.global().async {\n do {\n let data = try encoder.encode(value)\n DispatchQueue.main.async {\n completionHandler(data, nil)\n print("finish encode json")\n }\n } catch {\n DispatchQueue.main.async {\n completionHandler(nil, error)\n print("fail encode json")\n }\n }\n }\n }\n \n public func encodeJSON<T>(_ value: T, encoder: JSONEncoder) async throws -> Data where T: Encodable {\n \n try await withUnsafeThrowingContinuation { continuation …Run Code Online (Sandbox Code Playgroud) button ×10
flutter ×3
swift ×3
android ×2
back ×2
dart ×2
swiftui ×2
android-mvvm ×1
async-await ×1
data-binding ×1
iconbutton ×1
image ×1
ios ×1
java ×1
javascript ×1
jquery ×1
keyboard ×1
libgdx ×1
material-ui ×1
overlap2d ×1
reactjs ×1
textfield ×1
xcode ×1