In Android, how would you develop this? (a question of activity and views)

When the user opens the application, it has a screen with a button that says "login."

The user clicks a button and a web view appears so that he can log into the website.

After logging in (the application had to find out somehow), the web view will disappear, and then a list of usernames will appear. (ListView?)

When a user clicks on one of the usernames, a web view of the username profile opens. Of course, when the user clicks back, he returns to the list of usernames.

Can someone explain this to me in terms of Activity and Views ? Do I use two actions for this? Am I hiding a webview or list when a user clicks between them?

I made a tutorial (notepad tutorial), but I'm still confused about what is the best way to develop it.

thank

+3
source share
3 answers

When the user opens the application, it has a screen with a button that says "login". The user clicks a button and a web view appears so that he can log into the website. After logging in (the application should have somehow found out),

Yo Activity. WebView Activity. , View. , , Activity.

login Activity startActivityForResult(), , .

, WebView WebViewClient. WebViewClient WebView setWebViewClient().

- , ​​

Activity Intent finish() Activity. , , , .

, , - , -. , " " , , , , .

. (ListView?)

ListActivity. Activity, API, ListView.

, - . , "", .

onListItemClick() ListActivity, Activity, WebView . Activity, .

+3

, . , .

  • Activity (AndroidManifest.xml).
  • View ( , main.xml)
  • WebView
  • , View , ListView ( , XML , userlist.xml)
  • onClick WebView .

, "", onPause onResume, .

, .

EDIT:

An Activity - , AndroidManifest.xml . A View Activity, , , (WebView) ..

+1

, .

Andoid -. ListView . , WebView.

, , ! HttpRequest, .

- , , true/false . (php wrapper, xml )

, WebView, :

private void initWebView(final WebView mWebView) {
    mWebView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Page = new WebView(YourClass.this);
            Page.getSettings().setJavaScriptEnabled(true);
            Page.loadUrl(url);

            if(url.contains("OkDoLogIn.php")) {
                /* Check if login was successful if true start new Activity */
            }
            return true;
        }
    });
}

url.contains( "OkDoLogIn.php" ) , url . URL- URL- .

, !

: . 1- !

+1

Source: https://habr.com/ru/post/1731745/


All Articles