drawing chart with the help of google api - android

I am passing this url
String urlForLineChart ="http://chart.apis.google.com/chart?" +
"cht=lc&" +
"chs=200x125&" +
"chxl=0%3a|1|2|3|4|5|6|7|8|9|10&"+
"chd=t:10,3,5,8,15,20&"+
"chxt=x,y&"+
"chds=0,50&"+
"chxr=0,0,16%7C1,0,50&"+
"chm=s,FF0000,1,0,5";
To make a chart but it is not represent desired result kindly help me.
I am not getting that how to pass parameters. I searched a lot.
I am doing as follows
WebView mCharView = (WebView) findViewById(R.id.char_view);
mCharView.loadUrl(urlForLineChart);

You must enable Javascript in your webview:
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);

Related

How to load a string from strings.xml inside webview class

I have a class to load webpage:
webView = (WebView) findViewById(R.id.login_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://google.com");
I want to load a string from strings.xml instead of http://google.com. How can I do this ?
Just change your current code to this
webView = (WebView) findViewById(R.id.login_view);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(getResources().getString(R.string.url));
You just need to do that
String url = getResources().getString(R.string.url);

How can I read special character in webview?

I am developing an article managing android application, where articles are parsed through JSON.
All the values that are parsed by JSON are loaded in web view, but there are some special character that are not read by WebView.
{
web1 = (WebView) findViewById(R.id.webView2);
web1.setWebViewClient(new myWebClient());
web1.getSettings().setJavaScriptEnabled(true);
web1.loadData(c,"text/html", "UTF-32");
}
you can do like this way,
WebView webview = new WebView(collection.getContext());
webview.loadDataWithBaseURL(url, textWithQuotesIn, "text/html", "UTF-8", url);

Getting issue in android webview Text alignment

I am new to android. I am developing epub reader for android devices. webview shows text in left alignment. i want it to be justify. i am not sure this is text alignment problem.
This is my webview settings:
final WebView mainWebView = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
mainWebView.setWebViewClient(new MyCustomWebViewClient());
mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mainWebView.loadUrl("my html page");// loding my html pages here
mainWebView.getSettings().setUseWideViewPort(true);
i used this code for text alignment
mainWebView.loadUrl("javascript:(function addCSSRule(selector, newRule) { " +
"var mySheet = document.styleSheets[0];"+
"if (mySheet.addRule) { " +
"mySheet.addRule(selector, newRule);" +
"} else {"+
"ruleIndex = mySheet.cssRules.length;"+
"mySheet.insertRule(selector + '{' + newRule + ';}', ruleIndex);" +
"}"+
"})addCSSRule(selector, newRule)");
mainWebView.loadUrl("javascript:addCSSRule('p', 'text-align: justify;');");
if i remove mainWebView.getSettings().setUseWideViewPort(true); means i am getting justify text.
Screenshot of webview:
i want it to be like this:
i don't know whats wrong in my code. mainWebView.getSettings().setUseWideViewPort(true); allows to zoom. don't know why it kills text alignment. please help me to overcome this issue.
Thanks in advance.
It doesn't seem like you're applying your webSettings to the web view. I'm looking for something along the lines of
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
so perhaps your javascript isn't firing because it's not on... ?

android/java replace string to bold or some color in webview in html

i have a string ticker..
ticker="hdfc:123:-1.90 tcc:231:+1.3 as continue to hundreds of
ticker will get from the server. i just want to bold the name... so help me to find my solution.....
here is my code...
tiker = TickerConnection.getInstance().Ticker();
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);String summary = "<html><body><MARQUEE>"+tiker+"</MARQUEE></body></html>";
mWebView.loadData(summary, "text/html", "utf-8");
hey following is ur solution... u jst have to add tag <b>
tiker = TickerConnection.getInstance().Ticker();
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);String summary = "<html><body><MARQUEE><b>"+tiker+"</b></MARQUEE></body></html>";
mWebView.loadData(summary, "text/html", "utf-8");

android webview marquee string can't replace some string with image

i want to reaplace + with up.png imagae bt image is not generated on webview..... so give me help.
thanks in advance.
str = str.replaceAll("\\+","<img src=drawable/up.png/ >");
WebView web = (WebView) findViewById(R.id.webview);
String summary = "<html><body><marquee>"+str+"</marquee></body></html>";
web.loadData(summary, "text/html", "utf-8");
I think that your img src location is incorrect. Check out this question. I think the src should be 'file:///android_res/drawable/up.png'.

Categories

Resources