2012-08-28 12 views
5

मेरे पास कुछ HTML टैग के साथ डेटा है, और मैं इसे वेब व्यू में प्रदर्शित करना चाहता हूं।वेबव्यू में डेटा लोड नहीं हो रहा है लेकिन यह लॉक के बाद लोड होता है - अनलॉक डिवाइस

मैं नीचे दिए गए कोड की कोशिश की:

String html = "<html><body><font face=\"verdana\" size=\"" 
       + getResources().getString(R.string.WebView_Font_Size) 
       + "\" color=\"rgb(64,64,64)\">" 
       + Article.getDetaildescription().replaceAll("h2", "h4") 
       + "</font></body></html>"; 
String mime = "text/html"; 
String encoding = "utf-8"; 
Log.e("htmlstring", html); 
description.loadDataWithBaseURL(null, html, mime, encoding, null); 

जारी करना है: जब भी ऊपर कोड वेबव्यू में कार्यान्वित करता है, कुछ भी नहीं भार। लेकिन जैसे ही मैं डिवाइस को लॉक करता हूं & इसे अनलॉक करता है, मेरा वेबव्यू उस डेटा को प्रदर्शित करता है।

+0

logcat –

+0

logcat – rajpara

+0

में कोई त्रुटि की कोशिश करता है, तो यह काम करता है पोस्ट करें ("फ़ाइल: ///android_asset/your_html.html"); ** –

उत्तर

0

प्रयास करें

wv.loadDataWithBaseURL(null,html,"text/html","utf-8","about:blank"); 
+0

अभी भी वही है, हल नहीं किया गया है – rajpara

0

आप डेटा लोड करने से पहले जावास्क्रिप्ट सक्षम कर सकते हैं।

String strWeb = "<div style=\"text-align: center;\"><span class=\"Apple-style-span\" style=\"font-weight: normal; font-size: medium; \"><img src=\"http://mobileecommerce.site247365.com/admin/assetmanager/images/gns_header.jpg\" alt=\"\" align=\"middle\" border=\"1px\" height=\"90\" width=\"550\"></span></div><span class=\"Apple-style-span\" style=\"color: rgb(105, 105, 105); font-family: Verdana; font-size: 13px; font-weight: normal; \"><br><div style=\"text-align: center;\">Yes we are coming at E & I? Are you?</div></span><br><h1 style=\"font-weight: bold; \"><span style=\"font-family: Verdana; font-size: 14pt; \">News for the day...</span></h1><span style=\"color: rgb(105, 105, 105); \"><span style=\"font-family: Tahoma; font-size: 10pt; \">Template Mobile Sites for IC: <a href=\"http://icmobilesite.vidushiinfotech.net/\">http://icmobilesite.vidushiinfotech.net/</a></span><br><span class=\"Apple-style-span\" style=\"font-family: Tahoma; font-size: 13px; color: rgb(105, 105, 105); \">Promotional valid till 30 Sept 2011: MOBILE WEBSITE (Base Product Mobile CMS) for JUST $159<br></span></span><br><span style=\"font-family: Tahoma; font-size: 10pt; color: rgb(105, 105, 105); \">Mobile Template link: </span><a href=\"http://newsletter.vidushiinfotech.net/Mobilesite/\"><span class=\"Apple-style-span\" style=\"font-size: 15px; font-family: Calibri, sans-serif; color: rgb(105, 105, 105); \">http://newsletter.vidushiinfotech.net/Mobilesite/</span><br></a><span style=\"font-size: 10pt; font-family: Tahoma; \"><span style=\"font-size: 10pt; \"><br><span style=\"color: rgb(105, 105, 105); \">With the promotion on Business Edge and eFusion still running successful in e market place - $ 499</span><br><span style=\"color: rgb(105, 105, 105); \">Check out some of the latest site launch on: </span><br><br><span style=\"color: rgb(105, 105, 105); font-weight: bold; \">http://www.randallcontracting.co.uk/Pages/Default.aspx </span><br><br><span style=\"color: rgb(105, 105, 105); font-size: 10pt; \"><span style=\"font-weight: bold; \">Category</span>: Building & Construction</span><br></span><br></span><div style=\"color: rgb(105, 105, 105); text-align: left; \"><span style=\"font-size: 10pt; font-family: Tahoma; \">Description: WELCOME TO RANDALL CONTRACTING Randall Contracting is a family-run contracting SME which has been servicing London and the South East since 1956. Working closely with our Clients and external Design Consultants, we place great emphasis on a safe, positive, practical and common sense approach to our projects. Our delivery methods have resulted in an extensive volume of repeat business from both Private and Public Sectors. Safety and Environmental concerns are a high priority on all our contracts and we continually strive to source innovative working methods and solutions. Our equipment is regularly updated and maintained to ensure minimal environmental impact.</span><br><br></div><span style=\"color: rgb(105, 105, 105); font-weight: bold; font-family: Tahoma; \"><span style=\"font-size: 10pt; \"><br></span></span><br>"; 
    WebView webview = new WebView(this); 
    setContentView(webview); 
    webview.getSettings().setJavaScriptEnabled(true); 
    webview.loadData(html,"text/html","utf-8"); 
1

आपका कोड ठीक लगता है। अपनी एक्सएमएल फाइल की जांच करें जो आपकी मदद कर सकती है .. मुझे आश्चर्य है कि क्या आप गतिशील रूप से किसी भी लेआउट या किसी चीज़ की दृश्यता सेट कर रहे हैं ..

0

जैमिन उत्तर से मुझे संकेत मिला।

मेरी पुरानी लेआउट फ़ाइल में अन्य रैखिक लेआउट में एक रैखिक लेआउट होता है, इसलिए मैं सामग्री को लपेटने के लिए वेबव्यू की ऊंचाई बदलता हूं, पैरेंट & को भरने के लिए स्क्रॉल व्यू की चौड़ाई भी बदलता हूं, एक अनावश्यक लीनियरआउट हटा दें।

मुद्दे के साथ पुराने लेआउट

<include 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    layout="@layout/header_layout" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/title_background" 
    android:padding="5dp" > 

    <Button 
     android:id="@+id/Article_Detail_Share" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:layout_gravity="right|center_vertical" 
     android:background="@drawable/button_share" /> 

    <TextView 
     android:id="@+id/Article_Detail_Header" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_gravity="center" 
     android:layout_marginRight="5dp" 
     android:layout_toLeftOf="@id/Article_Detail_Share" 
     android:gravity="center" 
     android:padding="2dp" 
     android:text="Quarterly Issue - 10/2011" 
     android:textColor="@color/black" 
     android:textSize="@dimen/s16sp" 
     android:textStyle="bold" /> 
</RelativeLayout> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:layout_weight="1" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 



      <ImageView 
       android:id="@+id/Article_Detail_Image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_margin="5dp" 

       android:padding="2dp" 
       android:scaleType="fitCenter" 
      android:adjustViewBounds="true" 
       android:src="@drawable/image_box_big" /> 

      <TextView 
       android:id="@+id/Article_Detail_Title" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="9dp" 
       android:layout_marginRight="3dp" 
       android:layout_marginTop="3dp" 
       android:gravity="left|center_vertical" 
       android:textColor="@color/text_header_red" 
       android:textSize="@dimen/s20sp" /> 

      <TextView 
       android:id="@+id/Article_Detail_Author" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="3dp" 
       android:layout_marginLeft="9dp" 
       android:layout_marginRight="3dp" 
       android:textColor="@color/black" 
       android:textSize="@dimen/s11sp" 
       android:textStyle="italic" /> 
     </LinearLayout> 

     <WebView 
      android:id="@+id/Article_Detail_Web_Description" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_margin="3dp" 
      android:layout_weight="1" /> 

     <Gallery 
      android:id="@+id/Article_Detail_Image_Gallery" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      android:gravity="left" 
      android:spacing="5dp" /> 
    </LinearLayout> 
</ScrollView> 

<include 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    layout="@layout/bottom_layout" /> 

अपडेट किया गया लेआउट फ़ाइल

<include 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    layout="@layout/header_layout" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/title_background" 
    android:padding="5dp" > 

    <Button 
     android:id="@+id/Article_Detail_Share" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:layout_gravity="right|center_vertical" 
     android:background="@drawable/button_share" /> 

    <TextView 
     android:id="@+id/Article_Detail_Header" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:layout_gravity="center" 
     android:layout_marginRight="5dp" 
     android:layout_toLeftOf="@id/Article_Detail_Share" 
     android:gravity="center" 
     android:padding="2dp" 
     android:text="Quarterly Issue - 10/2011" 
     android:textColor="@color/black" 
     android:textSize="@dimen/s16sp" 
     android:textStyle="bold" /> 
</RelativeLayout> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <!-- <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > --> 



      <ImageView 
       android:id="@+id/Article_Detail_Image" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:layout_margin="5dp" 

       android:padding="2dp" 
       android:scaleType="fitCenter" 
      android:adjustViewBounds="true" 
       android:src="@drawable/image_box_big" /> 

      <TextView 
       android:id="@+id/Article_Detail_Title" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="9dp" 
       android:layout_marginRight="3dp" 
       android:layout_marginTop="3dp" 
       android:gravity="left|center_vertical" 
       android:textColor="@color/text_header_red" 
       android:textSize="@dimen/s20sp" /> 

      <TextView 
       android:id="@+id/Article_Detail_Author" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="3dp" 
       android:layout_marginLeft="9dp" 
       android:layout_marginRight="3dp" 
       android:textColor="@color/black" 
       android:textSize="@dimen/s11sp" 
       android:textStyle="italic" /> 
     <!-- </LinearLayout> --> 

     <WebView 
      android:id="@+id/Article_Detail_Web_Description" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="3dp"/> 

     <Gallery 
      android:id="@+id/Article_Detail_Image_Gallery" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      android:gravity="left" 
      android:spacing="5dp" /> 
    </LinearLayout> 
</ScrollView> 

<include 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    layout="@layout/bottom_layout" /> 

मुझे पता है कि स्क्रॉल व्यू के अंदर वेबव्यू & गैलरी होने का अच्छा दृष्टिकोण नहीं है बल्कि इसकी परियोजना आवश्यकता है। ** webview.loadUrl:

संबंधित मुद्दे