最佳实践活动 - 切换和寻像在Android的改变 [英] Best Practice activity- switching and view- changing in android

查看:105
本文介绍了最佳实践活动 - 切换和寻像在Android的改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还在寻找最佳的解决方案如何使用它们的布局与菜单和工具栏和充气或Android的启动活动。我的问题可能听起来令人困惑,但即时通讯试图解释它的一个例子。

I am still searching for the best solution howto use a layout with a menu and a toolbar and inflate or start activities in android. My question may sound confusing, but im trying to explain it in an example.

可以说,即时通讯程序的Andr​​oid应用程序(惊喜..我真的)

Lets say im programming an android app (surprise.. i really do)

我的应用程序可以执行以下操作:

My app can do following:

  1. 用户可以登录[3]或注册[2]。如果他登录,一个新的活动开始和他的仪表盘将显示。如果他注册:为registrationprocess的活动开始
  2. Registrationprocess:用户将他所需的用户名和密码,presses一个按钮接受。他的数据将被formvalidated,如果有效,新的活动开始,他可以选择自己的设置。后退按钮工作和数据可被传递到新的活动。在最后registrationwindow数据将被保存和仪表板开始。开始新的活动很有趣!
  3. 现在,多数民众赞成在它变得复杂。 Dasboard具有动作条(上)和一个栏(底部,如标签)。所以,一切要视口的中间部分进行查看(从现在起称为主视图)。没有更多的活动开关:(,寿。 目前,每个tabclick删除从主视图中的所有意见,并增加了其新的看法。很好看,可以是动画和工程就像一个魅力。例外情况:它目前不是动态
  1. User can log in [3] or register [2]. If he logs in, a new activity starts and his dashboard will be shown. If he registers: an activity for the registrationprocess starts.
  2. Registrationprocess: user puts in his desired username and password and presses a button to accept. His data will be formvalidated and if valid, a new activity starts where he can choose his settings. Backbutton works and data can be passed to the new activity. After the last registrationwindow data will be saved and dashboard started. Starting new Activities is fun!
  3. Now THATS where it gets complicated. Dasboard has an 'actionbar'(top) and a 'toolbar' (bottom, like tabs). So everything should be viewed in the middle part of the viewport(from now called main view). No more activity switching :(, tho. Currently each tabclick removes all views from the main view and adds its new view. Look great, can be animated and works like a charm. Except: its currently not dynamic.

所以...我不知道如何解决这个问题的最好办法。例如:我取的数据从一个Web服务,创建一个列表视图出它和它的扩展listactivity。本次活动我无法启动,但该数据需要被放入主视图。我怎么能做到这一点的最好方法是什么? 而且是有效的?

So... i don't know how to solve it the best way. For example: i fetch data from a webservice, create a listview out of it and it's extending listactivity. This activity i can't start but this data need to be put into the main view. How can i do it the best way? And is it efficient?

我练它实际上是我的第一个小讨论我要开始。所以...战斗! ;)

I'm practicing and it's actually my first small discussion i want to start. So... FIGHT! ;)

更新: 我已经看到了一个有趣的方式来启动活动,并取得成果。 <一href="http://stackoverflow.com/questions/3436970/launching-activity-through-intents/5605602#5605602">Launching通过意图活动 。是否有可能将新/活动后开始更新的意见?然后,我会产生我在一个单独的活动成果。更新视图。返回到仪表盘并加载刚才更新的观点。可能?还是低效的?我怎么可以更新查看了另外的活动?有这么多我需要学习:/

UPDATE: I've seen an interesting way to start activities and get results. Launching activity through intents . Is it possible to insert new/ update views after activity started? I would then generate my results in a separate activity. Update the view. Return back to 'dashboard' and load the view that was just updated. Possible? Or inefficient? And how can i update a view out of another activity? There is so much i need to learn :/

UPDATE2: 一个应用程序,已经做了一个很好的例子:Google+的 太糟糕了,我没有其源$ C ​​$ C;)

UPDATE2: A good example of an app that has done it: Google+ Too bad i don't have their sourcecode ;)

UPDATE3: 什么是最好的?

  • 在加载一个新的活动,禁用动画和设置选择工具箱选项卡+ 禁用后退按钮的功能
  • startActionForResults,取结果,并更新当前视图(还是真的不知道怎么这将是可能的)
  • viewFlipper onflip改变翻转视图+更新数据。
  • load a new activity, disable animation and set selected toolbox tab + disable backbutton functionality
  • startActionForResults, fetch results and update current view (still don't really know how that would be possible)
  • viewFlipper onflip changing+updating data in flipped view.

我还是不知道任何有效的解决方案。还是我失去了一些东西必不可少的?我刚刚完成我的ListActivity从我的web服务获取数据。但它仍然运行在单独的活性。我怎样才能实现它变成我的主视图现在呢? Ofcourse ...我可以设置列表我的自定义适配器。但是,目前的IM更新和从服务器上获取数据时我创建listactivity。

I still don't know any efficient solution. Or am i missing something essential? I've just finished my ListActivity to fetch data from my webservice. But it still runs in a separate activity. How can i implement it into my "main view" now? Ofcourse... i could set a list my custom adapter. But currently im updating and fetching data from the server when i create the listactivity.

恐怕这可能是唯一的答案我会得到:在嵌入外部意向主要活动

Im afraid this could be the only answer i'll get: Embed external Intent in main Activity

UPDATE4:我想要的东西。 基于nininho的回答(谢谢!)我尝试以下方法:

UPDATE4: I'm trying something. Based on nininho's answer (thank you!) im trying the following approach:

  1. 开始Dashboardactivity并创建一个ViewFlipper。
  2. 在每个Toolbarclick重新presents一定ViewFlipper页面。
  3. 在每一页都有一个Listadapter实施,并显示不同的结果(不同的Web服务查询)。 (ListView中,GridView控件,与profileimage,不profileimage)
  4. 在Toolbarclick开始的AsyncTask或服务,并通知列表当前页的数据已经改变。 (ofcourse如果数据已更改)。切换到页面被点击。
  5. 实施updatefeature。在滚动到列表的底部=获取更多的数据,并添加它。 5分钟后,自动更新等列表。在更新按钮点击或更新列表。

赞成到目前为止的:后退按钮独立于整个活动。页面翻转动画可能。名单仍然有可能的异步更新,切换到另一个列表。

PROs so far: Backbutton standalone for whole activity. Page-flip-animation possible. Async updating of lists and still possible to switch to another list.

缺点:的...有人有什么?那么这种方法的效率?请问ViewFlipper携带的所有信息,这样的性能会下降还是在viewflipper回收其意见(如ListView的)?

CONs: ... someone has any? What about efficiency of such an approach? Does the ViewFlipper carry all the information so the performance would go down or does the viewflipper recycle its Views (like ListView)?

UPDATE5: 如果我有时间我会让这里的一切更读和分析讨论。不要气我的阅读我的垃圾;)

UPDATE5: If i have some time i will make everything here more read- and discussable. Don't be mad at me for reading my rubbish ;)

推荐答案

据我所知,你希望你的应用程序来启动,从互联网上后显示在主屏幕上这个数据读取一些数据。

From what I understand you want your app to start, fetch some data from the internet and after show this data on the main screen.

我没有看到第二个活动的需要,你想用它只能读取数据,因为从你的解释读取数据,所以最好的办法是:

I don't see the need of a second activity to fetch the data because from your explanation you want to use it only to fetch the data, so the best approach would be:

  1. 创建一个活动(仪表盘)
  2. 在后台获取数据启动一个AsyncTask的或服务。
  3. 当读取结束,通知它结束了活动。
  4. 更改仪表板显示列表(可以使用ViewSwitcher如果你想要一些动画或刚刚创建的列表中选择布局不可见的,然后变成可见的)。

PS:你可以使用一个ListView一个ListActivity外,只需创建一个ListAdapter创建ListView的项目,而这是为ListView适配器

ps: you can use a ListView outside of a ListActivity, just create a ListAdapter to create the ListView items and add this as the adapter for the ListView.

这篇关于最佳实践活动 - 切换和寻像在Android的改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆