我有一个UIButton.我想使用相同的方法UIButton来执行多个操作.首先,我以编程方式将操作设置为按钮.
button1.addTarget(self, action: #selector(ViewController.function1), forControlEvents: .TouchUpInside)
Run Code Online (Sandbox Code Playgroud)
接下来,我想丢弃该功能,并希望添加其他操作.
button1.addTarget(self, action: #selector(ViewController.function2), forControlEvents: .TouchUpInside)
Run Code Online (Sandbox Code Playgroud)
是否可以覆盖按钮的现有目标?
从Android 5.0开始,他们提供媒体投影库来捕获屏幕内容.但他们提供的示例演示应用程序并不清楚.您可以在此处找到示例应用.在该应用程序中,他们使用virtualdisplay方法投影捕获的屏幕
private void setUpVirtualDisplay() {
Log.i(TAG, "Setting up a VirtualDisplay: " +
mSurfaceView.getWidth() + "x" + mSurfaceView.getHeight() +
" (" + mScreenDensity + ")");
mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture",
mSurfaceView.getWidth(), mSurfaceView.getHeight(), mScreenDensity,
DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
mSurface, null, null);
mButtonToggle.setText(R.string.stop);
}
Run Code Online (Sandbox Code Playgroud)
我想将捕获的屏幕转换为mp4文件,用于我的屏幕录制应用程序.请帮我解决这个问题.
我singleTop在我的主要使用模式Activity.我在用SearchWidget
这对我来说很明显MainAcivity:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
Run Code Online (Sandbox Code Playgroud)
onNewIntent 被叫两次:
protected void onNewIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
// here is my code
}
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样?