Objective
Hello everyone, to bring you Android开发工程师文集-Android知识点讲解 an overview, I hope you like
WebView explanation
The browser of the system is generally called via intent:
Uri uri = Uri.parse(url);Intent intent = new Intent(Intent.ACTION_VIEW,uri);startActivity(intent);
What is webview, in fact the literal understanding of the word can be, you can know that Android provides this element to display the page.
Next, you need to create a layout file about WebView:
<WebView android:id="@+id/WebView" android:layout_width="match_parent" android:layout_height="match_parent"</WebView>
If you use WebView, you need to use the Loadurl () method to make the call and load the page we want. This method can invoke a Web resource, or it can call local resources that we have directly written.
1. webView.loadUrl("http://janshu.com");2. webView.loadUrl("本地资源");3. webView.requestFocus();
What does this mean, it means open directly
Webview.setwebviewclient (New Webviewclient ());
public boolean shouldOverrideUrlLoading(WebView view,String url){ view.loadUrl(url); return true;}
Open with JavaScript
WebView webView = findViewById(R.id.webview);WebSttings webSettings = webView.getSettings();webSettings.setJavaScriptEnabled(true);
Check out the onkeydown () method to exit the program:
public boolean onKeyDown(int keyCode, keyEvent event){ if(keyCode==KeyEvent.KEYCODE_BACK){ if(webView.canGoBack()){ webView.goBack(); return true; } else { System.exit(0);//退出程序 } } return super.onKeyDown(keyCode, event);}
Use the following to display the loading process:
Setwebchromeclient ()->new webchromeclient ()
ProgressDialog
Turn on the display of the progress bar:
private void openDialog(int newProgress){ if(dialog==null){ dialog=new ProgressDialog(MainActivity.this); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTL); dialog.setProgress(newProgress); dialog.show(); } else{ dialog.setProgress(newProgress);}
To close a progress bar:
private void closeDialog(){ if(dialog!=null&&dialog.isShowing()){ dialog.dismiss(); dialog=null; }}
Fragment
FragmentManager fragmentManager = getFragmentManager();FragementTransaction beginTransaction = fragmentManager.beginTransaction();
Dynamic is most commonly used and can be handled by the method of Add (), remove (), replace (), commit (), Addtobackstack () fragment
The life cycle of fragment
Its life cycle is affected by activity.
Start fragment:
Onattach ()->oncreate ()->oncreateview ()->onactivitycreated ()->onstart ()->onresume ()
Turn it off:
Onattach ()->oncreate ()->oncreateview ()->onactivitycreated ()->onstart ()->onresume ()
OnPause ()->onstop ()
Restart:
Onattach ()->oncreate ()->oncreateview ()->onactivitycreated ()->onstart ()->onresume ()
OnPause ()->onstop ()
OnStart ()->onresume ()
Start a second fragment:
OnPause ()->onstop ()->ondestroyview ()->ondestroy ()->ondetach ()->onattach ()->oncreate () Oncreateview ()->onactivitycreated ()->onstart ()->onresume ()
Top Navigation
Viewpager
<android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center"/>
If you feel good, then you can order a praise!??
Summarize
- Android Development Engineer Anthology-android Knowledge Points -documenting the good life, if you have a better understanding, welcome to communicate
- Positioning: Sharing
Android & Java knowledge points, interested to continue to follow
Android Development Engineer Anthology-android Knowledge Point explanation