在Android中,你会如何发展呢? (活动和观点的问题) [英] In Android, how would you develop this? (activity and views question)
问题描述
当用户打开应用程序,有上有一个按钮,它说一个屏幕登录。
在用户点击按钮和一个web视图弹出,让他登录到该网站。
在登录之后(应用程序需要知道某种方式),web视图就会消失,然后用户名列表将弹出。 (ListView的?)
当用户点击用户名中的一个,该用户名的个人资料的WebView功能会弹出。当然,当用户按下返回,它返回到用户名的列表。
有人可以解释这对我的活动和浏览方面?我使用两项活动来做到这一点?难道我隐藏的WebView或ListView当用户点击它们之间?
我做了教程(记事本教程),但我仍然困惑,什么是发展最好的方法。
感谢
当用户打开应用程序,有上有一个按钮,它说一个屏幕登录。用户点击该按钮,和web视图弹出,让他登录到该网站。登录后(应用程序需要知道某种方式),
哟可以用两个独立的活动
类做到这一点。我会把的WebView
在自己的活动
。这比管理许多不同的更容易查看
对象自己。此外,你会得到不同的事物之间的转换,如果你把每个部分在自己的活动
。
您将可以启动登录活动
与<一个href="http://developer.android.com/reference/android/app/Activity.html#startActivityForResult%28android.content.Intent,%20int%29"相对=nofollow>的 startActivityForResult()
方法,允许其返回如果登录成功与否。
如果您要检测的登录,您可以监视使用在的WebView
事件 WebViewClient
。您可以设置 WebViewClient
你的的WebView
使用<一个href="http://developer.android.com/reference/android/webkit/WebView.html#setWebViewClient%28android.webkit.WebViewClient%29"相对=nofollow> setWebViewClient()
方法。
web视图就会消失,
只需启动下一个活动
使用意图
并调用的的完成()
方法一>你的第一个活动
。如果你这样做,那么使用中不会回来的登录按钮的活动,如果他们单击后退,因为它不会是堆栈中的任何更多。
什么我不清楚是登录的网站多久会有效。您可能需要设置活动的标志在你的清单一>,以确保用户如果他们离开,然后返回到您的应用程序再次登录。
,然后用户名列表将弹出。 (ListView的?)
使用一个 ListActivity
。这是一个活动
附带专为显示API一个的ListView
。
当用户点击用户名中的一个,该用户名的个人资料的WebView功能会弹出。当然,当用户按下返回,它返回到用户名的列表。
所以,使用<一个href="http://developer.android.com/intl/fr/reference/android/app/ListActivity.html#onListItemClick%28android.widget.ListView,%20android.view.View,%20int,%20long%29"相对=nofollow> onListItemClick()
在 ListActivity
方法来检测触摸并推出了新的活动
包含的WebView
来显示轮廓。由于这是一个新的活动
后面的操作都是自动完成的。
When the user opens the application, there is a screen with a button on it, which says "login."
The user clicks on the button, and a webview pops up to allow him to log in to the website.
After logging in (the app would need to know somehow), the webview would disappear, and then a list of usernames will pop up. (ListView?)
When the user clicks on one of the usernames, a webview of the username's profile will pop up. Of course, when the user pushes "back", it goes back to the list of usernames.
Can someone explain this to me in terms of Activity and Views? Am I using two activities to do this? Do I hide webview or listview when the user clicks between them?
I did the tutorial (notepad tutorial), but I'm still confused as to what is the best way to develop this.
Thanks
When the user opens the application, there is a screen with a button on it, which says "login." The user clicks on the button, and a webview pops up to allow him to log in to the website. After logging in (the app would need to know somehow),
Yo can do this with two separate Activity
classes. I would put the WebView
in its own Activity
. This is easier than managing lots of different View
objects yourself. Also, you'll get transitions between different things if you put each part in its own Activity
.
You'll can launch the login Activity
with the startActivityForResult()
method, allowing it to return if the login was successful or not.
If you want to detect the login, you can monitor events in a WebView
using a WebViewClient
. You set the WebViewClient
of your WebView
using the setWebViewClient()
method.
the webview would disappear,
Simply start the next Activity
using an Intent
and call the finish()
method on your first Activity
. If you do this then the use won't come back to login button Activity if they click back as it won't be on the stack any more.
What I'm not clear on is how long the login at the website will be valid for. You may need to set the flags on the Activities in your Manifest, to ensure the user has to log in again if they leave and then return to your application.
and then a list of usernames will pop up. (ListView?)
Use a ListActivity
. This is an Activity
which comes with the API designed for displaying a single ListView
.
When the user clicks on one of the usernames, a webview of the username's profile will pop up. Of course, when the user pushes "back", it goes back to the list of usernames.
So use the onListItemClick()
method in ListActivity
to detect the touch and launch a new Activity
containing the WebView
to show the profile. As this is in a new Activity
the back handling is all automatic.
这篇关于在Android中,你会如何发展呢? (活动和观点的问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!