Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Mobile Application Development BSCS-7 Lecture # 10 UI Controls – Spinner • Spinner widget is like a drop-down menu, and it manages its data through an adapter. Steps 1. Add spinner from widgets 2. Tell the adapter how to display data • • Just like ListView, the choices you provide for spinner can come from any source, but must be provided through an SpinnerAdapter, i. such as an ArrayAdapter if the choices are available in an array ii. or a CursorAdapter if choices are available from database query. I have provided data to ArrayAdapter using two ways: i. XML String array ii. Java String array 3. Responding to user selections • Use setOnItemSelectedListener method of spinner • Through Java • Through XML UI Controls – WebView • WebView class is an extension of Android’s View class that allows to display web pages as part of activity layout. • It does not include any feature of a fully developed browser. • If you want full browser working, then invoke a browser application with a URL Intent rather than show it with WebView. For example: Uri uri = Uri.parse("http://www.example.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); • To provide a WebView in your own Activity, include a <WebView> in your layout, or set the entire Activity window as a WebView during onCreate(): WebView webview = new WebView(this); setContentView(webview); • Then load the desired web page: // Simplest usage: an exception will NOT be thrown if there is an error loading this page (see below). webview.loadUrl("http://www.google.com"); // OR, you can also load from an HTML string: String summary = "<html><body>You scored <b>192</b> points.</body></html>"; webview.loadData(summary, "text/html", null); UI Controls – WebView Steps to Add WebView 1. Add WebView from widgets in App 2. Application must have permission to use internet. To get access, request the INTERNET permission in androidmanifest file. 3. To load a web page in WebView, use loadUrl(String) 4. Using JavaScript in WebView i. ii. If the web pages use JavaScript, you must enable it in WebView Enabling JavaScript • It is disable by default. • You can enable it through WebSettings attached to your WebView. Retrieve WebSettings with getSettings(), then enable JavaScript with setJavaScriptEnabled() Zoom • To enable built-in zoom, set WebSettings.setBuiltInZoomControls(boolean) (introduced in API level CUPCAKE). • NOTE: Using zoom if either height or width is set to WRAP_CONTENT may lead to undefined behavior and should be avoided. UI Controls – WebView Handling page navigation • To open links clicked by the user, provide a WebViewClient for your WebView using setWebViewClient(). For example; vWeb.setWebViewClient(new WebViewClient()); Sr.No 1 2 3 4 5 6 7 8 Method & Description canGoBack() This method specify that whether the WebView has a back history item. canGoForward() This method specify that whether the WebView has a forward history item. clearHistory() This method will clear the WebView forwad and backward history. destroy() This method destory the internal state of WebView. findAllAsync(String find) This method find all instances of string and highlight them. getProgress() This method gets the progress of the current page. getTitle() This method return the title of the current page. getUrl() This method return the url of the current page. UI Controls – TimePicker h UI Controls – DatePicker h