图文混排加webview跳转
来源:互联网 发布:数控铣削平面编程实例 编辑:程序博客网 时间:2024/06/08 11:34
package com.bwei.test.wangyajie1508a20170627;import android.graphics.Paint;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.webkit.WebSettings;import android.webkit.WebView;import android.webkit.WebViewClient;import android.widget.Button;import android.widget.TextView;import static com.bwei.test.wangyajie1508a20170627.R.id.webview;public class MainActivity extends AppCompatActivity { Button btn; WebView webView; TextView textView; String str = "http://www.baidu文字.com"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView) findViewById(R.id.tv); btn = (Button) findViewById(R.id.btn); webView = (WebView) findViewById(webview); // Toast.makeText(MainActivity.this,str,Toast.LENGTH_SHORT).show(); final String s = str.replace("文字", "");// Toast.makeText(MainActivity.this, s, Toast.LENGTH_SHORT).show(); textView.setText(s); textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {// Toast.makeText(MainActivity.this, "113121", Toast.LENGTH_SHORT).show(); webView.setVisibility(View.VISIBLE); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); webView.loadUrl(s); webView.setWebViewClient(new WebViewClient(){ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); } }); }}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.bwei.test.wangyajie1508a20170627.MainActivity"> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="文字-"/> <ImageView android:background="@mipmap/ic_launcher" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-文字"/> </LinearLayout> <Button android:id="@+id/btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="baidu"/> <WebView android:id="@+id/webview" android:layout_width="wrap_content" android:layout_height="wrap_content"> </WebView></LinearLayout>
阅读全文
0 0
- 图文混排加webview跳转
- WebView 跳转
- webview自适应图文详情
- webview 实现可控跳转
- Webview处理302跳转
- WebView实现内部跳转
- webView跳转网站集合
- 跳转显示webview网页
- webview的页面跳转
- WebView跳转网络地址
- 跳转到webview界面
- webview跳转加载数据
- 点击跳转显示WebView
- WebView 跳转传值
- android_跳转WebView
- 自定义ViewPager+WebView跳转
- webView实现图文混排
- webview高度自适应图文详情
- 逆欧拉函数
- MVVM模式
- okhttp异常java.lang.IllegalStateException: closed
- PHP还是世界上最好的语言吗?
- 【LeetCode】C# 13、Roman to Integer
- 图文混排加webview跳转
- nginx的重写和url美化
- Android中图片的三级缓存
- 和为S的两个数字
- 构造回文
- HttpURLConnection一个适配器加载图片的类
- JAVA注意事项(二)
- HTML的响应式和多媒体技术
- HDU 4474(Yet Another Multiple Problem)(BFS+同余定理)