可以一起使用intellij idea和eclipse(Is it possible to use intellij idea and eclipse together)
对于某人来说,它可能看起来有点奇怪,但我仍然想知道它是否可能。 到目前为止,我们有许多项目编写了eclipse编码,我们中的一些人想要进入intellij创意世界。
我们能够同时通过eclipse和intellij一起运行项目吗? 我的意思是,例如我将使用intellij想法,而我的另一个朋友将在同一个项目中使用eclipse而不是intellij想法,这可能吗?
如果可能的话,它是否会为版本控制系统(例如颠覆)造成任何问题?
for someone it may seems a little weird but still I want to know if it's possible or not. We have a lot of projects which coded on eclipse so far and some of us wants to jump into intellij idea world.
Can we be able to run the projects via eclipse and intellij together at the same time? I mean for instance I'll be using intellij idea while another friend of mine will be using eclipse instead of intellij idea on the same projects, is it possible?
If it's possible, would it create any problem for version control systems such as subversion?
原文:https://stackoverflow.com/questions/21160987
最满意答案
通过在
Activity
中创建匿名Runnable
类,您将创建对外部类的隐式引用,从而泄漏活动的上下文。 您的延迟Toast消息将在主线程消息队列中继续,从而防止对您的活动上下文进行垃圾收集。使用带有对活动上下文的弱引用的静态处理程序(静态内部类不包含对其外部类的隐式引用)。
private final ToastHandler mHandler = new ToastHandler(this); private static class ToastHandler extends Handler { private final WeakReference<MainActivity> mActivity; public ToastHandler(MainActivity activity) { mActivity = new WeakReference<>(activity); } @Override public void handleMessage(Message msg) { MainActivity activity = mActivity.get(); Bundle data = msg.getData(); if (activity != null) { Toast.makeText(activity, data.getString("TEST_KEY"), Toast.LENGTH_LONG).show(); } } } private static final Runnable runnable = new Runnable() { @Override public void run() { Message message = new Message(); Bundle bundle = new Bundle(); bundle.putString("TEST_KEY", "TEST"); message.setData(bundle); mHandler.handleMessage(message); } };
在你的onClick ...
mHandler.postDelayed(runnable, 1000);
编辑:哎呀,你的runnable需要是静态的
By creating an anonymous
Runnable
class within anActivity
you are creating an implicit reference to your outer class, thereby leaking the context of the activity. Your delayed toast message will continue in the main thread message queue preventing a garbage collect of your activity context.Use a static handler with a weak reference to your activity context (Static inner classes do not hold an implicit reference to their outer class).
private final ToastHandler mHandler = new ToastHandler(this); private static class ToastHandler extends Handler { private final WeakReference<MainActivity> mActivity; public ToastHandler(MainActivity activity) { mActivity = new WeakReference<>(activity); } @Override public void handleMessage(Message msg) { MainActivity activity = mActivity.get(); Bundle data = msg.getData(); if (activity != null) { Toast.makeText(activity, data.getString("TEST_KEY"), Toast.LENGTH_LONG).show(); } } } private static final Runnable runnable = new Runnable() { @Override public void run() { Message message = new Message(); Bundle bundle = new Bundle(); bundle.putString("TEST_KEY", "TEST"); message.setData(bundle); mHandler.handleMessage(message); } };
In your onClick...
mHandler.postDelayed(runnable, 1000);
Edit: Oops, your runnable needs to be static ofc
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
创建一个Utils类: public class Utils { public static void showToast(String msg, Context ctx) { Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show(); } } 从Activity中使用它: Utils.showToast("Message", this); 来自片段: Utils.showToast("Message", getActivi ...
-
BroadcastReceivers一直在使用后立即销毁。 我不确定它是否在某些先前版本的Android中发生了变化,但您绝不应该假设广播接收器的实例会保留。 它们的目的是立即处理事件,延迟处理应该使用AlarmManager或在服务中进行。 BroadcastReceivers are always destroyed immediately after use. I'm not sure if it changed in some previous version of Android, but you ...
-
我会说,古典错误: 您忘记了Toast.show()方法;) I would say, classical error : You forgot the Toast.show() method ;)
-
我想知道是否有一个非常大的scheduledTime变量(假设它代表了几天),处理程序仍将执行runnable? 是的,如果Handler发布的服务和线程将在当时存活。 或者我应该更好地使用AlarmManager吗? 是。 I want to know if having a very big scheduledTime variable (lets say it represents a couple of days), the handler will still execute the runnab ...
-
处理程序需要在showResult()方法中,或者在调用showResult()之后需要调用它,因为mRunnable不存在。 The handler needs to be inside the showResult() method or you need to call it after you call showResult() because mRunnable doesn't exist as you have it.
-
这里是另一方面 private int z=0; Runnable r = new Runnable() { @Override public void run() { Toast.makeText(play.this, "z:" + z, Toast.LENGTH_SHORT).show(); if(z<4){ z++; h ...
-
通过在Activity中创建匿名Runnable类,您将创建对外部类的隐式引用,从而泄漏活动的上下文。 您的延迟Toast消息将在主线程消息队列中继续,从而防止对您的活动上下文进行垃圾收集。 使用带有对活动上下文的弱引用的静态处理程序(静态内部类不包含对其外部类的隐式引用)。 private final ToastHandler mHandler = new ToastHandler(this); private static class ToastHandler extends Handler { ...
-
Toast中没有文字(No text in Toast)[2022-05-07]
我犯了一些错误,因为吐司没有显示任何文字。(那时候我刚接触到android编程) 我犯了什么错误 我没有使用Shared Preferences来存储我的数据。 由于我的接收器是动态注册的。 吐司仅在应用程序运行时或在后台显示。 在EditText输入文本后,我关闭了我的应用程序并将其从最近的应用程序中删除。 然后,我再次打开了应用程序, 它创建了一个新的实例,我认为那里的数据实际上并不存在,并且吐司中没有文本。 我还要感谢Onik的耐心和帮助。 I made few mistakes because of ... -
Android中的Toast消息(Toast Message in Android)[2022-03-18]
这很简单。 只要您不想再显示ToastMessage,就可以在ToastMessage上调用cancel方法。 参考Toast取消() This is quite simple. Just call the cancel method on your ToastMessage as soon as you don't want to show the ToastMessage anymore. Refer Toast cancel()