Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 演示API/在多个视图上重定向操作_Java_Android_View_Actionlistener - Fatal编程技术网

Java 演示API/在多个视图上重定向操作

Java 演示API/在多个视图上重定向操作,java,android,view,actionlistener,Java,Android,View,Actionlistener,我正在处理一个以前创建的项目,不想扔掉他们的大部分代码。因此,我想做一些事情,比如在像setText这样的视图上复制动作,设置动画。。。在不同的对象上,但在相同的视图上: 如果它能像这样工作,我会多么高兴: someView.addViewChangeListener(new ViewChangeListener() { public void onViewChangedAction(ViewChangedAction action) {

我正在处理一个以前创建的项目,不想扔掉他们的大部分代码。因此,我想做一些事情,比如在像setText这样的视图上复制动作,设置动画。。。在不同的对象上,但在相同的视图上:

如果它能像这样工作,我会多么高兴:

someView.addViewChangeListener(new ViewChangeListener()
    {
        public void onViewChangedAction(ViewChangedAction action)
            {
                myotherviewobject.executeAction(action)
            }
    });
这将是最简单的方法,但我还没有找到一个API来做到这一点。实际上有多个自定义视图等,所以我需要一个非常通用的解决方案。这样的解决方案存在吗

如果不是。。。关于如何以一种可用的方式做到这一点而不干扰他人的代码,有什么想法吗


提前感谢。

如果您的愿景是希望触摸屏上的一部分内容镜像到演示文稿中,我的想法是。特别是,MirrorPresentationFragment和MirrorWebViewFragment等源代码为您提供了示例应用程序中所示的代码:

/***
  Copyright (c) 2013 CommonsWare, LLC

  Licensed under the Apache License, Version 2.0 (the "License"); you may
  not use this file except in compliance with the License. You may obtain
  a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
 */

package com.commonsware.cwac.preso.demo;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Display;
import com.commonsware.cwac.preso.MirrorPresentationFragment;
import com.commonsware.cwac.preso.MirroringWebViewFragment;
import com.commonsware.cwac.preso.PresentationFragment;
import com.commonsware.cwac.preso.PresentationHelper;

public class MirrorPresentationActivity extends Activity implements
    PresentationHelper.Listener {
  PresentationFragment preso=null;
  PresentationHelper helper=null;
  MirroringWebViewFragment source=null;

  @SuppressLint("SetJavaScriptEnabled")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.mirror_presentation);

    helper=new PresentationHelper(this, this);
    source=
        (MirroringWebViewFragment)getFragmentManager().findFragmentById(R.id.source);
    source.getWebView().getSettings().setJavaScriptEnabled(true);
    source.getWebView().loadUrl("http://commonsware.com");
  }

  @Override
  public void onResume() {
    super.onResume();
    helper.onResume();
  }

  @Override
  public void onPause() {
    helper.onPause();
    super.onPause();
  }

  @Override
  public void clearPreso(boolean switchToInline) {
    if (preso != null) {
      preso.dismiss();
      preso=null;
    }
  }

  @Override
  public void showPreso(Display display) {
    preso=buildPreso(display);
    preso.show(getFragmentManager(), "preso");
  }

  private PresentationFragment buildPreso(Display display) {
    MirrorPresentationFragment result=
        MirrorPresentationFragment.newInstance(this, display);

    source.setMirror(result);

    return(result);
  }
}
净效果是用户在活动的WebView中所做的任何操作都将镜像到演示文稿中

因为它使用相同的视图对象。。。它还会继承相同的更改吗?或者甚至显示相同的视频


镜像类主要涉及将镜像源的内容绘制到位图,以及将其绘制到屏幕。任何在封面下使用SurfaceView或TextureView的东西都不起作用,但其他东西一般都可以。因此,视频无法通过镜像工作。为此,我会尝试在演示文稿上显示它,使用手机/平板电脑作为控制器。

如果您的愿景是希望将触摸屏上的一部分内容镜像到演示文稿上,我的库就有。嘿。这太棒了!但是,镜像到演示文稿只是第一个用例。这实际上是进入镀铬的第一步,我希望有一个类似的方法。就像onViewChangedAction创建某种消息一样,cc上的html5/js支持这种消息。然而,我不认为这是真正可行的一种方便的方式。所以我现在就把它扔掉。你的方法现在简单多了,我不知道我实际上可以重用片段的膨胀视图。。请回答,我一开始就接受!+因为它使用相同的视图对象。。。它还会继承相同的更改吗?或者甚至显示相同的视频?是的,还是?