I implemented the the Android webview encounter some problem
Beginning do a OptionMenu, and he will appear when you press the Menu four locations
I use the mouse click taipei he displayed to Toast
But I would like to implement the functionality Toast message screen webview display the specified web page
I use Intent a = new Intent (Intent.ACTION_VIEW, Uri.parse ();
startActivity (a);
Can successfully display the webpage
But I would like to the webview implement web pages using setContentView ();
Switch to taipei.xml <= webview, when I click on the submit button, it could not display the webpage using webview
Please help me to see where the problems lie, because beginners just learning, I hope to try to attach the code to solve my problem.
Code URL: [I implemented the the Android webview encounter some problem
Beginning do a OptionMenu, and he will appear when you press the Menu four locations
I use the mouse click taipei he displayed to Toast
But I would like to implement the functionality Toast message screen webview display the specified web page
I use Intent a = new Intent (Intent.ACTION_VIEW, Uri.parse ("http://www.taipei-101.com.tw/"));
startActivity (a);
Can successfully display the webpage
But I would like to the webview implement web pages using setContentView ();
Switch to taipei.xml <= webview, when I click on the submit button, it could not display the webpage using webview
Please help me to see where the problems lie, because beginners just learning, I hope to try to attach the code to solve my problem.
Code URL: http://www.javaworld.com.tw/jute/post/view?bid=26&id=312960&sty=1#312960
And attach performed on screen picture
And attach performed on screen picture in the cod URL
Implore help thank you
Related
Any one knows how to detect click event of play button of iframe/video in HTML which is loaded in web-view.
in HTML Page contains like
<p><iframe width="100%" src="youtube.com/embed/uxpDa-c-4Mc"></iframe></p>
and i need to detect click event of Playvideo button in android webview.
Give the element an id, do the following in Javascript (I am assuming you have JQuery, your question itself is lacking details in many ways as I write this right now, you should really try to give more information in order to get answers).
EDIT: My solution to the iframe/jquery issue would be to use a video element instead of an iframe. Here is how: Show Youtube video source into HTML5 video tag?
We would then continue to use the below JS/JQuery
Example JQuery:
$('play').on("click", function() {
//Do something
});
Example with shortcut implemented:
$('play').click(function() {
//Do something
});
I created an application in android to connect to mongodb. the programs main page consists of a loading a webpage via webview in my system, i used apache as application server. in apache, inside www folder all my php and html pages are there , and i am able to load those pages, and from that page i can go to all the pages and back via the application itself, my question is that while i go from one page to another, can a toast messege be shown in the screen?. i mean as a notification can a toast message be displayed when a page link is clicked from the emulator?
my question is that while i go from one page to another, can a toast
message be shown in the screen?. i mean as a notification can a toast
message be displayed when a page link is clicked from the emulator?
=> Yes you can use WebViewClient for your WebView to achieve that. You can write Toast notification code inside shouldOverrideUrlLoading() method.
i mean as a notification can a toast message be displayed when a page
link is clicked from the emulator?
If you want to show a message to User when "URL are going to be loaded" you need to assign WebViewClient to your WebView.
All what you need to do is override for example onPageStarted() method1:
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// show message to Use
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
1Or also you can override shouldOverrideUrlLoading() method.
There is a rather specific webpage loaded into WebView which URL is like http://www.site.com/mob/ (basically a mobile-optimized web page). This webpage display 25 articles only and on the bottom is a button "More articles".
When a user presses it, I catch URL http://www.site.com/Web/MobHomeItems.aspx?page=N (where N is 2, 3, 4...) and after that another 25 items have been loaded on the same screen.
Now, when I click on some article and go to article details, and later return to the page via the Back key, the WebView forgets how many articles have been loaded and simply loads the default page with 25 displayed articles. Imagine how frustrating this would be to a user if he came to 100th article.
I tried overriding many methods in WebClient and in WebChromeClient, but so far I have been unable to load N number of pages loaded via "More Articles" button. For example, I first thought this would help, but it did not.
#Override
public void onLoadResource(WebView view, String url) {
//http://www.site.com/Web/MobHomeItems.aspx?page=2
if (url.contains("?page=")) {
//save this URL for later and on return from
// article details, pass it to LoadResource()
super.onLoadResource(view, url);
}
Then I tried similar approach with other method - basically remembering how many pages have been loaded on the main page, and then on return from article details, simply tell webview to load this URL.
Can anyone help me? How to append loaded pages to the main page? Should I use JavaScript here maybe?
PS. Loading mentioned URL http://www.site.com/Web/MobHomeItems.aspx?page=N does not help as it loads this concrete page into the WebView only, and it does not append this Nth page to the main page.
EDIT
As #Raghunandan asked, I do not have problems loading back to 1st page (?page=1). This is default when user presses Back button on article details. I want to load to the page where a user was before pressing article details. If he was on ?page=100, I want to load back to that page e.g. I want to have 25x100 articles open. Again, default is always "open 25 articles or ?page=1 or http://www.site.com".
Override the method shouldOverrideUrlLoading of WebViewClient.
like this:
public boolean shouldOverrideUrlLoading (WebView view, String url) {
if (url is kind of article detail) {
WebView newOne = new WebView(); // create a new Webview for displaying the details.
view.setVisibility(View.INVISIBLE); // hiding current page (article list)
return true; // To tell the WebView we have process this url.
}
return false;
}
The user click one link of article's detail.
shouldOverriderUrlLoading would be triggered.
We created one new WebView to open the url.
Hiding current page
The user reading artical
The user click back key, close the newOne WebView then make the
previous WebView visible.The article list will show up immediately and remained the old statement
.
There is a another way to do this.
The WebSettings has a private method "setPageCacheCapacity" , the default value is 0 , you could enlarge it (may be 5).
You can access this method by using reflection of java.
The method can enable WebView to cache more than one document. In the other word. when user press the back key, the WebView will go back to the older document.
i am new with android and i try to create Epub reader.
i already read Epub Files in Android Webview and now i am taring create find functionality
i use this code for find any text in webview it works fine but wane i am go to next page
in my app stile my webview display find items .
code :
int i = webViewRead.findAll(text);
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webViewRead, true);
So, my problem is how to hide the result.
I already try to create new instants of my Webview( and Relode Webview Like webViewRead.reload(); ) but its not work for me.
is any anther way to do it.??
(my content witch i display in webview is xhtml pages).
And one More Thing with this method find text is highlighted with Green color
is their any way to display find text in Red color.
Why not use:
webViewRead.clearMatches();
?
Greg
I take the response from an HTTP connection in the form of string and show that to webview like this:
WebView engine = (WebView)findViewById(R.id.webview);
engine.loadData(endResult, "text/html", "UTF-8"); /*endresult is string*/
I actually get a response that contains the google page (google search result direct from google.com).
The loadData method works well i.e it shows the web page but when I click on one of the links on that page it shows "page not available" and said that "xyz link might be temporarily down or it may have moved to permanently to a new web address".
this happens for all links accept the first present link on that page. i.e it shows correct page from first link on that page but fails for others..
I noticed that OSes prior to 2.3 failed to follow links if setHorizontalScrollBarEnabled and setVerticalScrollBarEnabled are set to false.
try to use loadDataWithBaseURL of the WebView class
I would avoid using engine.loadData - it seems to cause all sorts of crazy problems.
Use engine.loadDataWithBaseURL instead, and pass the base URL of where the content exists. I would think that the content you are loading is using relative paths in it's HTML so it's looking inside your app resources. By specifying the base URL you get around this problem.