将屏幕坐标从按钮传递给父级

2023-12-26

我正在为 Android 制作一个钢琴应用程序。作为示例(测试),我的活动中有 4 个按钮。家长是一个Relative Layout我还有一些文本视图可以告诉手指触摸的屏幕坐标。还有一个 textView("Entered Button") 可以检测您的手指是否位于按钮上
它看起来是这样的:

我使用下面给出的代码实现了这一点。

Java

public class MainActivity extends Activity {

Button b1, b2, b3, b4;

int b1x1, b1x2, b1y1, b1y2;

private TextView xcordview;
private TextView ycordview;
private TextView buttonIndicator;
private RelativeLayout touchview;
private static int defaultStates[];
private Button mLastButton;
private final static int[] STATE_PRESSED = {
        android.R.attr.state_pressed,
        android.R.attr.state_focused  
                | android.R.attr.state_enabled };

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    xcordview = (TextView) findViewById(R.id.textView4);
    ycordview = (TextView) findViewById(R.id.textView3);
    buttonIndicator = (TextView) findViewById(R.id.button_indicator);
    touchview = (RelativeLayout) findViewById(R.id.relativelayout);

    b1 = (Button) findViewById(R.id.button1);
    b2 = (Button) findViewById(R.id.button2);
    b3 = (Button) findViewById(R.id.button3);
    b4 = (Button) findViewById(R.id.button4);
    defaultStates = b1.getBackground().getState();

}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();

    touchview.setOnTouchListener(new View.OnTouchListener() {

        private boolean isInside = false;

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            int x = (int) event.getX();
            int y = (int) event.getY();

            xcordview.setText(String.valueOf(x));
            ycordview.setText(String.valueOf(y));

            for (int i = 0; i < touchview.getChildCount(); i++) {
                View current = touchview.getChildAt(i);
                if (current instanceof Button) {
                    Button b = (Button) current;

                    if (!isPointWithin(x, y, b.getLeft(), b.getRight(), b.getTop(),
                            b.getBottom())) {
                        b.getBackground().setState(defaultStates);
                    }

                    if (isPointWithin(x, y, b.getLeft(), b.getRight(), b.getTop(),
                            b.getBottom())) {
                        b.getBackground().setState(STATE_PRESSED);
                        if (b != mLastButton) {
                            mLastButton = b;
                            buttonIndicator.setText(mLastButton.getText());
                        }
                    }

                }
            }
            return true;
        }

    });

}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    // TODO Auto-generated method stub
    super.onWindowFocusChanged(hasFocus);
}

static boolean isPointWithin(int x, int y, int x1, int x2, int y1, int y2) {
    return (x <= x2 && x >= x1 && y <= y2 && y >= y1);
}
}

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="10dp"
    android:text="Y Cord : "
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="10dp"
    android:text="X Cord : "
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_toRightOf="@+id/textView"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#000000" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView"
    android:layout_marginBottom="10dp"
    android:layout_toRightOf="@+id/textView"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#000000" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:text="B1"
    android:textColor="#000000" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button1"
    android:text="B2"
    android:textColor="#000000" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button2"
    android:text="B3"
    android:textColor="#000000" />

<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/button3"
    android:text="B4"
    android:textColor="#000000" />

<TextView
    android:id="@+id/button_indicator"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/textView4"
    android:layout_marginRight="33dp"
    android:text="No one"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/button_indicator"
    android:layout_alignBottom="@+id/button_indicator"
    android:layout_marginRight="29dp"
    android:layout_toLeftOf="@+id/button_indicator"
    android:text="Entered: "
    android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

因此,上面给出的代码工作正常,因为它可以识别当我从任何按钮上的空白区域(相对布局)滑动手指时。但是当我从一个按钮滑动到另一个按钮时,它不起作用。它没有得到任何坐标,也没有感觉到我的手指放在了哪个按钮上。下图最好地解释了当我从一个按钮滑动到另一个按钮时会发生什么。

那么如何在从一个按钮滑动到另一个按钮时获取坐标呢?


MainActivity.java

    package com.example.touch;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.MotionEvent;
    import android.view.View;
    import android.widget.Button;
    import android.widget.RelativeLayout;
    import android.widget.TextView;

    public class MainActivity extends Activity {

        MyButton b1, b2, b3, b4;

        int b1x1, b1x2, b1y1, b1y2;

        private TextView xcordview;
        private TextView ycordview;
        private TextView buttonIndicator;
        private RelativeLayout touchview;
        private static int defaultStates[];
        private Button mLastButton;
        private final static int[] STATE_PRESSED = {
                android.R.attr.state_pressed,
                android.R.attr.state_focused  
                        | android.R.attr.state_enabled };

        @Override
        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            xcordview = (TextView) findViewById(R.id.textView4);
            ycordview = (TextView) findViewById(R.id.textView3);
            buttonIndicator = (TextView) findViewById(R.id.button_indicator);
            touchview = (RelativeLayout) findViewById(R.id.relativelayout);

            b1 = (MyButton) findViewById(R.id.button1);
            b2 = (MyButton) findViewById(R.id.button2);
            b3 = (MyButton) findViewById(R.id.button3);
            b4 = (MyButton) findViewById(R.id.button4);
            defaultStates = b1.getBackground().getState();

        }

        @Override
        protected void onResume() {
            // TODO Auto-generated method stub
            super.onResume();

            touchview.setOnTouchListener(new View.OnTouchListener() {

                private boolean isInside = false;

                @Override
                public boolean onTouch(View v, MotionEvent event) {

                    int x = (int) event.getX();
                    int y = (int) event.getY();

                    xcordview.setText(String.valueOf(x));
                    ycordview.setText(String.valueOf(y));

                    for (int i = 0; i < touchview.getChildCount(); i++) {
                        View current = touchview.getChildAt(i);
                        if (current instanceof Button) {
                            Button b = (Button) current;

                            if (!isPointWithin(x, y, b.getLeft(), b.getRight(), b.getTop(),
                                    b.getBottom())) {
                                b.getBackground().setState(defaultStates);
                                b.getBackground().setAlpha(255);
                            }

                            if (isPointWithin(x, y, b.getLeft(), b.getRight(), b.getTop(),
                                    b.getBottom())) {
                                b.getBackground().setState(STATE_PRESSED);
                                b.getBackground().setAlpha(150);
                                b.performClick();

                                if (b != mLastButton) {
                                    mLastButton = b;
                                    buttonIndicator.setText(mLastButton.getText());
                                }
                            }

                        }
                    }
                    return true;
                }

            });

        }

        @Override
        public void onWindowFocusChanged(boolean hasFocus) {
            // TODO Auto-generated method stub
            super.onWindowFocusChanged(hasFocus);
        }

        static boolean isPointWithin(int x, int y, int x1, int x2, int y1, int y2) {
            return (x <= x2 && x >= x1 && y <= y2 && y >= y1);
        }
    }

我的按钮.java

package com.example.touch;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Button;

public class MyButton extends Button {

    public MyButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

    public MyButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public MyButton(Context context) {
        super(context);
        // // TODO Auto-generated constructor stub
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        // return super.onTouchEvent(event);
        return false;
    }

}

布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativelayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff" >

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:text="Y Cord : "
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/textView"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:text="X Cord : "
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView2"
        android:layout_toRightOf="@+id/textView"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#000000" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/textView"
        android:layout_marginBottom="10dp"
        android:layout_toRightOf="@+id/textView"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#000000" />

    <com.example.touch.MyButton
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="B1"
        android:textColor="#000000" />

    <com.example.touch.MyButton
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/button1"
        android:text="B2"
        android:textColor="#000000" />

    <com.example.touch.MyButton
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/button2"
        android:text="B3"
        android:textColor="#000000" />

    <com.example.touch.MyButton
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/button3"
        android:text="B4"
        android:textColor="#000000" />

    <TextView
        android:id="@+id/button_indicator"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/textView4"
        android:layout_marginRight="33dp"
        android:text="No one"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button_indicator"
        android:layout_alignBottom="@+id/button_indicator"
        android:layout_marginRight="29dp"
        android:layout_toLeftOf="@+id/button_indicator"
        android:text="Entered: "
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

将屏幕坐标从按钮传递给父级 的相关文章

  • Android 卷页动画

    我对 Android 动画有点陌生 目前我正在开发一个故事活动 需要像 iPhone 中那样使用卷页动画 我发现 iPhone 中有一种方法可以做到这一点 但我仍然找不到在android中做的方法 所以请帮我解决这个问题 谢谢大家 谷歌代码
  • 包管理器已去世

    我收到一位安装了很多应用程序的用户发来的邮件 称当我的应用程序使用以下代码收集活动信息时 他遇到了问题 getPackageManager queryIntentActivities mAinIntent 0 完整来源在这里 https g
  • ViewFlipper中的VideoView在播放视频时是透明的

    我有一个 Activity 在 ViewFlipper 中设置了两个视图 其中一个视图是带有 GLSurfaceView 和一些其他小部件的布局 另一个视图只有带有 TextView 和 VideoView 的布局 当我单击 GLSurfa
  • 在Java中测试服务器是否启动的正确方法?

    简单地查看是否可以建立与网站 服务器的连接的正确方法是什么 我想要这个用于我正在编码的应用程序 如果我的网站离线 它只会提醒我 Thanks 您可以使用 HttpURLConnection 发送请求并检查响应正文中是否有该页面特有的文本 而
  • 手机重置后AlarmManager闹钟不触发

    在我的应用程序中 用户加入一个计划 然后第二天中午会出现警报通知 这是我的代码 首先 我在 AlarmManager 中设置一个闹钟 如下所示 set alarm to the next day 12 00 noon of the join
  • 当前版本的Android Gradle插件不支持按需配置

    升级到 Android Studio 3 1 2 后 出现以下错误 当前版本的 Android Gradle 插件不支持按需配置 因为您使用的是 Gradle 4 6 或更高版本 建议 通过在 gradle properties 文件中设置
  • Android:如何让设备只运行一个应用程序?

    我有一个客户项目 我必须制作单任务 Android 设备 客户无法逃脱我公司开发的应用程序 此外 客户无法启动任何其他应用程序 而我们的应用程序会在设备启动时启动 总体而言 客户能够使用设备执行的所有操作就是运行我们的应用程序 除了 roo
  • 使用Picasso从url保存图像?

    我正在尝试使用 API Picasso 保存图像 为了做到这一点 我正在尝试使用Target保存 但我无法完成这项工作 我怎么能这样做呢 Trying save image public static void imageDownload
  • Firebase Messaging FCM 在可配置的时间间隔内分发

    当您使用 FCM 向给定应用程序的所有设备发送推送时 这可能会导致许多用户同时打开他们的应用程序 从而导致大量服务器轮询 从而导致负载峰值 有没有一种方便的方法可以在给定的时间间隔内分发消息以进行计划推送 最后 我们找到了一种可能的方法 通
  • 无法在 Android 上编译 avahi

    我是交叉编译的新手 我被分配了使用android补丁的任务http avahi org ticket 354 http avahi org ticket 354将 avahi 核心编译为 android ndk build avahi co
  • Android ViewModel LiveData 在按钮单击时更新视图

    我正在关注这个tutorial https developer android com topic libraries architecture guide html common problems faced by app develop
  • Android WebView文件上传

    我正在开发一个 Android 应用程序 基本上它是一个WebView和一个进度条 Facebook 的移动网站 m facebook com 已加载到WebView 当我单击 选择文件 按钮上传图像时 没有任何反应 我已经尝试了所有的解决
  • ProgressBar.setInminateDrawable() 不起作用

    当我尝试更改我的 indeteminateDrawable 进度条就消失了 我必须更改我的进度条的可绘制对象 我尝试了invalidate requestLayout等 我不知道如何解决它 谢谢 这里的代码 progressBar setI
  • Android volley使用RequestFuture.get()时出现超时异常

    在我的片段中 我尝试使用 TMDB 的开放电影数据库来获取有关 正在播放 电影的详细信息 如果我使用 RequestFuture get time TimeUnit 方法来执行此齐射请求 我总是会收到超时错误 如果我在 Safari 中手动
  • 数据未刷新“DynamiteModule:未找到 com.google.firebase.auth 的本地模块描述符类”

    我已经使用 Firebase 很长时间了 到目前为止 除了以下场景之外 一切都很好 有时我注意到我的应用程序不再获取新数据 我正在用一个活跃的监听器监听变化 并且我确实有keepSynced set to true 发生这种情况时 我会在日
  • 如何为 flutter 绘图应用实现橡皮擦功能

    有一个关于通过 flutter 创建绘图应用程序的视频 YouTube https www youtube com watch v yyHhloFMNNA 它支持当用户点击屏幕时绘制线 点 但我找不到像 Android 本机那样擦除用户绘制
  • Android Jetpack Compose 尺寸随持续时间变化的动画

    如何在 Jetpack Compose 中添加内容大小更改动画的持续时间 尝试使用Modifier animateContentSize 并通过动画规格具有持续时间 但它只是突然进入或退出 没有观察到持续时间 Column Modifier
  • 如何解决android程序中的警告“从不本地读取”

    为什么我收到警告说 The field testscreen ScaleAnimToShow mVanishAfter is never read locally testscreen java testscreen src com tes
  • Android Volley - 发布请求 - 无法在线工作

    我试图通过 Volley 发出 POST 请求 它在我的本地主机中工作得很好 但是当我将它移动到网络服务器时 响应为空 Java代码 RequestQueue queue Volley newRequestQueue this String
  • 如何减少 Android 中浮动 editText 提示和 editText 框之间的空间?

    我有一个带有浮动提示的 EditText 但我想知道如何减少浮动提示和 EditText 框之间的空间 现在我的用户界面看起来像https i stack imgur com ltfra jpg https i stack imgur co

随机推荐

  • JFrame.getLocationOnScreen() 用于最小化窗口

    I call getLocationOnScreen http docs oracle com javase 6 docs api java awt Component html getLocationOnScreen 28 29 from
  • 我应该使用 Cygwin 安装哪些软件包才能使其不臃肿,同时又拥有我作为开发人员所需的一切? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 通常 我在虚拟机中运行 Linux 但是 我的大多数虚拟机都位于外部 HDD 上 我可能有也可能没有 我认为当我需要类似 Linux
  • 将结构成员 NAME 传递给 C 中的函数?

    有没有简单的方法可以将结构成员的名称传递给 C 中的函数 例如 如果我想实现这一点 我知道代码不正确 我只是为了解释问题而写的 struct Test int x int y int main struct Test t t x 5 t y
  • 如何修复深色模式无法跨多个 html 页面保留的问题?

    这是我上一个问题的后续问题 可以在这里找到如何实现将暗 亮模式功能保存到本地存储 https stackoverflow com questions 74764851 how do i implement the saving of dar
  • 为什么 getUserMedia() 在 chrome 中显示权限被拒绝错误

    我正在使用 getUserMedia 在 Node js 和 Angular 项目 MEAN 中进行视频流 我的
  • 停止过滤WordPress函数wp_insert_post

    我必须对 WordPress 构建的网站进行一些小的更改 并且我遇到了 wp insert content 函数的一些问题 该函数对输入进行清理 完全删除一些 HTML 标签 例如 并删除其他标签的属性 我想关掉它 我到处都能找到链接htt
  • 如何设置TextView的文本?

    我面临将文本设置为的问题TextView在android中我的代码是 public class Main extends Activity Override public void onCreate Bundle savedInstance
  • MatTableDataSource:无法读取未定义的属性“长度”

    我在使用角度材料数据表时遇到以下错误 我可以从 api 获取数据 但无法在视图中呈现它 Error 错误图像 https i stack imgur com CjT7x jpg TS dataSource new MatTableDataS
  • 如何在 .NET 中克隆字典?

    我知道我们应该使用字典而不是哈希表 但我找不到克隆字典的方法 即使我将其转换为 ICollection 来获取 SyncRoot 我知道这也是不受欢迎的 我现在正忙着改变这一点 我是否有正确的假设 即无法以通用方式实现任何类型的克隆 这就是
  • Ruby 中非常便宜的命令行选项解析

    编辑 请 please please在回复之前请阅读本文底部列出的两个要求 人们不断发布他们的新宝石和库等等 这显然不符合要求 有时我想以非常便宜的方式将一些命令行选项修改为一个简单的脚本 一种有趣的方法是 无需处理 getopts 或解析
  • 如何为使用 Vuex 存储的 Vue 表单组件编写 Jest 单元测试?

    我有一个登录表格 当我用数据填写登录表单并单击登录按钮时 表单数据 用户名 密码 被发送到服务器并得到响应 回 如果表单数据无效 则会显示一条消息
  • 在 Rails 中显示两个文本正文之间的差异

    有没有一种简单的方法可以做到这一点 创建标记文本来显示两段文本之间的更改 也许是一个内置的助手 看过但没找到 您可以使用 jsdifflib http snowtide com jsdifflib http snowtide com jsd
  • TabLayout高亮和波纹效果

    我对 TabLayout 有两个问题 1 我可以删除TabLayout突出显示或更改选项卡布局的突出显示颜色吗 2 我可以为选项卡添加涟漪效果吗 每个选项卡都包含 TextView 我尝试添加自定义背景 如下所示
  • 以编程方式更改 Gnome 终端主题

    我想在本地计算机 Ubuntu GNOME 上创建一个设置 终端窗口具有不同的背景颜色 具体取决于我是登录到本地计算机还是通过 ssh 连接到远程计算机 有没有办法做到这一点 这并不能满足您的要求 但它可能会满足您的要求 您可以修改您的 b
  • Material UI v1 - 设置表格列宽

    我想使用 css 在 Material UI 表上设置列宽 而不是在 React 中使用 类 但我不明白如何控制列宽 我尝试设置 TH 列的宽度 但它不起作用 参见示例 Material ui 表示例 https codesandbox i
  • 将 .RData 文件加载到 Python 中

    我有一堆 RData 时间序列文件 希望将它们直接加载到 Python 中 而不需要先将文件转换为其他扩展名 例如 csv 关于实现这一目标的最佳方法有什么想法吗 对于那些不想安装 R 来完成此任务 r2py 需要它 的人来说 作为替代方案
  • 正交投影 Python

    我使用正交投影来绘制地图 我使用这个程序 from mpl toolkits basemap import Basemap import numpy as np import matplotlib pyplot as plt import
  • 在视图模型中实现 IDataErrorInfo

    我有一个 ViewModel 类 其中一个 Phone 对象作为其属性之一 我的主窗口数据上下文设置为 ViewModel 我是否需要在基础 Phone 模型类或包含 Phone 属性的 ViewModel 类上实现 IDataErrorI
  • 设计用户的rails pg db迁移未定义方法“database_authenticatable”

    undefined method database authenticatable for
  • 将屏幕坐标从按钮传递给父级

    我正在为 Android 制作一个钢琴应用程序 作为示例 测试 我的活动中有 4 个按钮 家长是一个Relative Layout我还有一些文本视图可以告诉手指触摸的屏幕坐标 还有一个 textView Entered Button 可以检