导航视图上的Android-选项卡式视图

时间:2016-11-23 10:48:25

标签: android

我想在我的主页片段上添加标签视图.... 任何人都可以帮助我如何添加标签视图..我正在使用导航视图 这是代码

public class WebViewActivity extends AppCompatActivity {
    private static final String LINK_ADDRESS = "LINK_ADDRESS";
    private static final String BASE_ADDRESS = "http://www.google.es/search?q=";
    private static final String DEFAULT_ADDRESS = "";

    private WebView webView;
    private EditText editText;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

        webView = (WebView) findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());

        editText = (EditText) findViewById(R.id.edit);
        editText.setText(settings.getString(LINK_ADDRESS, DEFAULT_ADDRESS));

        Button change = (Button) findViewById(R.id.change);
        change.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                final SharedPreferences.Editor editor = settings
                        .edit();
                editor.putString(LINK_ADDRESS, editText.getText().toString());
                editor.apply();

                reloadWebView();
            }
        });

        reloadWebView();
    }

    private void reloadWebView() {
        webView.loadUrl(BASE_ADDRESS + editText.getText().toString());
    }
}

0 个答案:

没有答案