English 中文(简体)
控制流动,同时通知适应者和发射意向
原标题:Controlling flow while notifying adapter and firing intent at the same time

我正在撰写一份申请,要求使用双屏和刺.装置。

我有一种方法(要求一个州的新闻),它向适应者发出信号(在一屏幕上,即右活动),然后向另一个屏幕上显示的地图(即左派活动)发射意向。 这种方法如下:

public void onClick(View v) {

    MyAction.fireIntentToMap(context, myList); // fire intent to map on the left screen
    MyListAdapter.notifyDataSetChanged(); // adapter is for listview displayed on right screen
}

我想的是,首先应当向左屏幕上的地图活动发射意向,而且只有在(即显示意向中收到的物品的地图)之后,名单的改编者才应当得到通知,名单观点应当更新。

然而,情况并非如此。 确实发生的情况是,这一呼吁出现在<条码>射电/代码>中,其用意是发射(即:拨打<条码>启动(intent);。 然而,在地图上收到意向之前,执行,名单观点得到更新。 该图后来收到这一意向。

为什么发生这种情况? 我怎么能在这里找到一种单一的读写行为(地图过程意图首先,然后更新清单观点)?

.

问题回答

如你所知,你没有控制因诺言实际上“交付”。

There are several solutions to your problem, but IMO, the most elegant would be to use ordered broadcasts. So your map and list register (dynamically) to receive your broadcasts, with priority set so that they get called in desired order.

优先事项通过, 当你通过

然后由以下网站播放:http://developer.android.com/vis/android/content/Context.html#sendOrderedBroadcast%28android.content.Intent,%20java.lang.String%29”rel=“nofollow”,“Context.sendOrderedBroadcast(.)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签