sreymj Well-Known Member Dec 2, 2010 #1 How do you maintain HTML formatting with Html.fromHtml? The format is lost when displaying in a TextView.
How do you maintain HTML formatting with Html.fromHtml? The format is lost when displaying in a TextView.
V vinay1497 Lurker Dec 7, 2010 #2 Hi, I am new to Android.. i have already tried this...so it may be useful for you. We can render the HTML code in Android using HTML.fromHtml("Any String with HTML tags"); ---------------------------------------------- this.setContentView(R.layout.cartview); TextView text = (TextView) findViewById(R.id.ListView); text.setId(R.id.ScrollView01); text.setText(Html.fromHtml("HTML String")); -------------------------------------------- cartview.xml ---------------- <ScrollView android:id="@+id/ScrollView01" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:id="@+id/ListView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </ScrollView> ---------------- In the Android we can get the HTML Layout with scroll View. If you have any other ideas let me know. Thanks Vinay Guntaka
Hi, I am new to Android.. i have already tried this...so it may be useful for you. We can render the HTML code in Android using HTML.fromHtml("Any String with HTML tags"); ---------------------------------------------- this.setContentView(R.layout.cartview); TextView text = (TextView) findViewById(R.id.ListView); text.setId(R.id.ScrollView01); text.setText(Html.fromHtml("HTML String")); -------------------------------------------- cartview.xml ---------------- <ScrollView android:id="@+id/ScrollView01" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:id="@+id/ListView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </ScrollView> ---------------- In the Android we can get the HTML Layout with scroll View. If you have any other ideas let me know. Thanks Vinay Guntaka
sreymj Well-Known Member Dec 8, 2010 #3 As it turns out, I was approaching this all wrong. The correct solution is to use the WebView. WebView webview; webview = (WebView) findViewById(R.id.WebView01); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("http://someurl.com"); Hello, WebView | Android Developers
As it turns out, I was approaching this all wrong. The correct solution is to use the WebView. WebView webview; webview = (WebView) findViewById(R.id.WebView01); webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("http://someurl.com"); Hello, WebView | Android Developers