I want to show a html using webview, html json string is not passed over the label string, how to conduct the show?
There are pictures there follows a string of characters, as follows:
String htmlData = < p style = " text-align: center " > < img src = " http://f.expoon.com/news/2013 / 10/09/881020.jpg " title = " Tourism Commodities Fair Information Figure " alt = " Tourism Commodities Fair Information Figure " / > < / p > < p style = " text-align: center " > < strong > Tourism Commodities Fair Information Figure < / strong > < br / > < / p > < p style = " text-align: justify; " > < strong & gt; basic information < / strong > < / p > < p style = " text-align: justify; " > English name: Beijing Tourism Commodity Fair < / p > < p style = " text-align: justify; " > Industry: Travel / Hospitality / Catering < / p > < p style = " text-align: justify; " > Show time: 2013.10.10-2013.10.13 < / p > & lt ; p style = " text-align: justify; " > Area: Chaoyang District, Beijing, China < / p > < p style = " text -align: justify; " > exhibition Certification: Certification net exhibition < / p > < p style = " text-align: justify; " & ; gt; exhibition Address: No.16 East Third Ring Road, Chaoyang District, Beijing < / p > < p style = " text-align: justify; " & gt ; field & nbsp; & nbsp; Museum: National Agricultural Exhibition < / p > < p style = " text-align: justify; " > Organizer: Beijing Municipal Commission of Tourism Development < / p > < p style = " text-align: justify; " > Sponsor: Beijing Beijing International Convention and Exhibition Exhibition excellent Ltd. < / p > < p style = " text-align: justify; " > Supporters: China Tourism Association & ; lt ;/ p > < p style = " text-align: justify; " > < strong > Exhibition < / strong & gt; < / p > < p style = " text-align: justify; " > Organizer: Beijing Municipal Commission of Tourism Development < / p & ; gt; < p style = " text-align: justify; " > Supervisor: People's Republic of China National Tourism Administration < / p > < p style = " text-align: justify; " > Supporters: China Tourism Association < / p > < p style = " text-align : justify; " > Organizer: Beijing International Convention and Exhibition Exhibition excellent Ltd. < / p > < p style = " text-align: justify; " > Exhibition Time: October 10, 2013 至 13th (Preparation time October 8 -09 days) < / p > < p style = & quot ; text-align: justify; " > Venue: Beijing National Agricultural Exhibition < / p > < p style = " text-align: justify; & ; quot; > exhibition area: 30000 < / p > < p style = " text-align: justify; " > expected Merchant: 1000 < / p > < p style = " text-align: justify; " > Expected audience: 100,000 people < / p > & ; lt; p style = " text-align: justify; " > [idea] uphold < / p > < p style = " text- align: justify; " > theme of the show: a platform to share the win-win cooperation < / p > < p style = " text-align: justify; & quot ; > exhibition purposes: display quality, expand exchanges, strengthen cooperation and promote trade < / p > < p style = " text-align: justify; " > organized Objective: efforts to build three platforms, namely, to create a tourism product development design, production and marketing, purchasing and consumption on the downstream multi-docking platform for the exchange; Second, to create travel goods industry buyers and sellers to negotiate transactions platform; Third, build tourism product development demonstration platform to lead the industry. < / p > < p style = " text-align: justify; " >
I use webView.loadData (htmlData, "text / html", "utf-8");
Why not show it? Great God please advise. . . . . . . .
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
public class MainActivity extends Activity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
WebView wv = (WebView) findViewById (R.id.wvHtml);
String htmlData = "< p style = " text-align: center " > < img src = " http://f.expoon.com/news/ 2013/10/09/881020.jpg " title = " Tourism Commodities Fair Information Figure " alt = " Tourism Commodities Fair Information Figure " / > & lt ;/ p > < p style = " text-align: center " > < strong > Tourism Commodities Fair Information Figure < / strong & gt ; < br / > < / p > < p style = " text-align: justify; " > < strong & ; gt; basic information < / strong > < / p > < p style = " text-align: justify; " > Name : Beijing Tourism Commodity Fair < / p > < p style = " text-align: justify; " > Industry: Travel / Hotel / Restaurant < / p > < p style = " text-align: justify; " > Show time: 2013.10.10-2013.10.13 < / p > & lt; p style = " text-align: justify; " > Area: Chaoyang District, Beijing, China < / p > < p style = " text-align: justify; " > exhibition Certification: Certification net exhibition < / p > < p style = " text-align: justify; " > exhibition Address: No. 16, East Third Ring Road, Chaoyang District, Beijing < / p > < p style = " text-align: justify; " & gt; field & nbsp; & nbsp; Museum: National Agricultural Exhibition < / p > < p style = " text-align: justify; & quot ; > Organizer: Beijing Municipal Commission of Tourism Development < / p > < p style = " text-align: justify; " > Sponsor: Beijing Beijing International Convention and Exhibition Exhibition excellent Ltd. < / p > < p style = " text-align: justify; " > Supporters: China Tourism Association < / p > < p style = " text-align: justify; " > < strong > Exhibition < / strong & ; gt; < / p > < p style = " text-align: justify; " > Organizers: Beijing Tourism Development Committee < / p > < p style = " text-align: justify; " > Supervisor: People's Republic of China National Tourism Administration < / p > & lt ; p style = " text-align: justify; " > Supporters: China Tourism Association < / p > < p style = " text- align: justify; " > Organizer: Beijing International Convention and Exhibition Exhibition excellent Ltd. < / p > < p style = " text-align: justify ; " > Exhibition Time: October 10, 2013 至 13th (Preparation time October 8 -09 days) < / p > < p style = & quot; text-align: justify; " > Venue: Beijing National Agricultural Exhibition < / p > < p style = " text-align: justify; " > exhibition area: 30000 < / p > < p style = " text-align: justify; " > expected Merchant: 1000 home < / p > < p style = " text-align: justify; " > expected audience: 100,000 people < / p > < p style = " text-align: justify; " > [idea] uphold < / p > < p style = " text -align: justify; " > theme of the show: a platform to share the win-win cooperation < / p > < p style = " text-align: justify; & quot; > exhibition purposes: display quality, expand exchanges, strengthen cooperation and promote trade < / p > < p style = " text-align: justify; & quot ; > organized Objective: efforts to build three platforms, namely, to create a tourism product development design, production and marketing, purchasing and consumption on the downstream multi-docking platform for the exchange; Second, to create travel goods industry buyers and sellers to negotiate transactions platform; Third, build tourism product development demonstration platform to lead the industry. < / p > < p style = " text-align: justify; " > ";
htmlData = htmlData.replaceAll ("&", "");
htmlData = htmlData.replaceAll ("quot;", "\" ");
htmlData = htmlData.replaceAll ("lt;", "<");
htmlData = htmlData.replaceAll ("gt;", ">");
wv.loadDataWithBaseURL (null, htmlData, "text / html", "utf-8", null);
}
While adding AndroidManifest.xml network access configuration file:
Otherwise not show pictures.
Reply:
Thank you very much indeed a
Reply:
But there is a question to ask, after opening because it seems very large pictures online shows only the left half of the screen on the phone, did not seem the right side of the display, ask how to modify? As shown below:

Reply:
public class MainActivity extends Activity {
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
WebView wv = (WebView) findViewById (R.id.wvHtml);
wv.getSettings () setLayoutAlgorithm (LayoutAlgorithm.SINGLE_COLUMN);.
String htmlData = "< p style = " text-align: center " > < img src = " http://f.expoon.com/news/ 2013/10/09/881020.jpg " title = " Tourism Commodities Fair Information Figure " alt = " Tourism Commodities Fair Information Figure " / > & lt ;/ p > < p style = " text-align: center " > < strong > Tourism Commodities Fair Information Figure < / strong & gt ; < br / > < / p > < p style = " text-align: justify; " > < strong & ; gt; basic information < / strong > < / p > < p style = " text-align: justify; " > Name : Beijing Tourism Commodity Fair < / p > < p style = " text-align: justify; " > Industry: Travel / Hotel / Restaurant < / p > < p style = " text-align: justify; " > Show time: 2013.10.10-2013.10.13 < / p > & lt; p style = " text-align: justify; " > Area: Chaoyang District, Beijing, China < / p > < p style = " text-align: justify; " > exhibition Certification: Certification net exhibition < / p > < p style = " text-align: justify; " > exhibition Address: No. 16, East Third Ring Road, Chaoyang District, Beijing < / p > < p style = " text-align: justify; " & gt; field & nbsp; & nbsp; Museum: National Agricultural Exhibition < / p > < p style = " text-align: justify; & quot ; > Organizer: Beijing Municipal Commission of Tourism Development < / p > < p style = " text-align: justify; " > Sponsor: Beijing Beijing International Convention and Exhibition Exhibition excellent Ltd. < / p > < p style = " text-align: justify; " > Supporters: China Tourism Association < / p > < p style = " text-align: justify; " > < strong > Exhibition < / strong & ; gt; < / p > < p style = " text-align: justify; " > Organizers: Beijing Tourism Development Committee < / p > < p style = " text-align: justify; " > Supervisor: People's Republic of China National Tourism Administration < / p > & lt ; p style = " text-align: justify; " > Supporters: China Tourism Association < / p > < p style = " text- align: justify; " > Organizer: Beijing International Convention and Exhibition Exhibition excellent Ltd. < / p > < p style = " text-align: justify ; " > Exhibition Time: October 10, 2013 至 13th (Preparation time October 8 -09 days) < / p > < p style = & quot; text-align: justify; " > Venue: Beijing National Agricultural Exhibition < / p > < p style = " text-align: justify; " > exhibition area: 30000 < / p > < p style = " text-align: justify; " > expected Merchant: 1000 home < / p > < p style = " text-align: justify; " > expected audience: 100,000 people < / p > < p style = " text-align: justify; " > [idea] uphold < / p > < p style = " text -align: justify; " > theme of the show: a platform to share the win-win cooperation < / p > < p style = " text-align: justify; & quot; > exhibition purposes: display quality, expand exchanges, strengthen cooperation and promote trade < / p > < p style = " text-align: justify; & quot ; > organized Objective: efforts to build three platforms, namely, to create a tourism product development design, production and marketing, purchasing and consumption on the downstream multi-docking platform for the exchange; Second, to create travel goods industry buyers and sellers to negotiate transactions platform; Third, build tourism product development demonstration platform to lead the industry. < / p > < p style = " text-align: justify; " > ";
htmlData = htmlData.replaceAll ("&", "");
htmlData = htmlData.replaceAll ("quot;", "\" ");
htmlData = htmlData.replaceAll ("lt;", "<");
htmlData = htmlData.replaceAll ("gt;", ">");
wv.loadDataWithBaseURL (null, htmlData, "text / html", "utf-8", null);
}
No comments:
Post a Comment